Suppose the bootloader of an Android device is locked.
Is there any way to install a custom ROM without unlocking the bootloader? If yes, then how?
Yes, however, this method will not work on every phone.
You are now rooted and have a custom recovery installed; this is an enormous security risk, especially since anyone can delete your lockscreen password from recovery mode and hence have full access to your device.
If you brick your phone you will have a very hard time getting out of such a situation because your bootloader is locked.
I have personally tried this method before on a Nexus 5 running and Lollipop 5.1.1 LMY48M and it worked.
I would recommend going the "old-fashioned" way to root your device and unlock your bootloader.