Does the bootloader need to be unlocked to flash my phone I am not able to relate between bootloader unlocking and flashing. From what I understand, when I flash my phone with a custom ROM, it writes to the /boot partition and hence the bootloader has to be unlocked. Is my understanding correct, or can I flash a ROM without unlocked bootloader?
A locked bootloader means that you won't be able to install software updates(or flash recoveries, ROMs) that hasn't been signed by the manufacturer/carrier.

So the answer is "Yes, you can flash an unsigned ROM but it won't get loaded by the locked bootloader".