If you’re in the US and a citizen, you do not have to divulge your password to the authorities or even a judge, per the 5th Amendment. However, they can force you to use your fingerprint or FaceID to unlock your phone.
If you think there’s a chance the police might want to search your phone, be sure that you have a difficult pin pattern or password to unlock your phone at a minimum. Consider if bringing your phone is necessary. If you’re going to a protest, do not bring your primary phone. Get a cheap burner or go without.
If you’re not a citizen, you need to think about leaving. Seek asylum anywhere but here. Vacation in Canada. The US is no longer safe for foreigners.
On Android, hold the power button until the menu shows up, them choose “lockdown”. The next unlock will require a PIN.
On iOS, hold down power and volume up (like you’re going to power down or go into emergency mode) then cancel. Next unlock will require your PIN.
Another way on iOS is pressing the Power button 5 times. Same result, but I think it can be accomplished a little easier.