AFAIK, the only way you can reliably lock your bootloader with a custom firmware, is if the device allows you to upload new avb_custom_keys. This basically allows you change your locked bootloader to allow custom firmware from a single (signed) source (ie graphene, google, your own).
I can't say for certain, but many non-pixel phones do not support this.
So, if you were to lock your bootloader, the loader would notice that you have an "unauthorized" firmware installed and would not run it. You'd basically need to unlock the bootloader again, but I think Motorola has made this process more complicated. Meaning you might need a bootable device to do it.
As far as security: Unlocked phones are less secure. All android devices are encrypted, using a hardware key plus your pin number. When a device is locked, a "secure key" is used as the hardware key. When a device is unlocked "another key" is used. If an attacker gets a hold of your unlocked encrypted phone, they can easily get this "other hardware key" which means they already have 1/2 of the information needed to decrypt your phone.
Afterwards, the only thing protecting your unlock phone is the strength of your pin (which is trivial to brute force). On locked bootloaders, it's much more difficult, as they'd need to figure out the "secure key", in addition to your pin.