If that install attempt wouldn’t fail, it would be very, very surprising.
This very much depends on the device.
Some bootloaders should be perfectly lockable (e.g. Fairphone 3/3+), some should be but experienced issues temporarily (e.g. Fairphone 4), and some should indeed not be locked (e.g. every device with install instructions which don’t lock the bootloader).
Quick reminder: Locking as well as unlocking the bootloader will force a factory reset for security reasons.