how to put a password to enter android recovery mode? I want to have high security so that no one formats my phone without a password even in recovery mode.
You can't protect your recovery with a password.
It's useless because if someone has physical access to your phone, he could just boot into download/bootloader/fastboot mode and flash a custom recovery to bypass any security on your phone.
This is also the reason why no recovery offers password protection.