Once /e/OS has been installed, is it safe to re-lock the bootloader on my Xperia XZ2 Compact or will it screw everything up?
No, it is not possible; even with stock android.
Right. Sony do not allow you to re-lock the bootloader. This has been a source of frustration for me for the nearly 3 years my Xperia XA2 has been running /e/.
Whats the problem when the bootloader is not re-locked?
It is not possible to re-lock the bootloader of any Sony devices, at least not the ones supported by Sony’s Open Devices project:
If I change my mind later on, is there any way to restore my device?
No. Once you have unlocked the bootloader, you will not be able to revert the device back to a locked or original state or restore the DRM security keys. You can however use the Flash tool for Xperia™ devices to flash a generic Sony ROM, although it will not receive automatic software upgrades.
Annoying “OMG! It’s Unlocked!” message at boot time. And some banking apps are not happy with unlocked bootloaders. I also noticed that MySudo would not work.
Have a look at this post