App to lock the phone “right now”
[Apple] - Use Emergency SOS on your iPhone:
Press and hold the side button and one of the Volume buttons until the Emergency SOS slider appears.
This locks the screen and requires a pin:
If you use the Emergency SOS shortcut, you need to enter your passcode to re-enable Touch ID, even if you don't complete a call to emergency services.
If that doesn't work (iPhone 7 and earlier):
Rapidly press the side (or top) button five times.
Note that you may want to turn off "Auto Call", to avoid accidentally calling emergency services. This can be done in the "Emergency SOS" settings.
You can use AssistiveTouch (Settings > General > Accessibility) where a tiny bubble floats on the screen. You can set it such that holding it locks the phone, or double-tapping it does it, or single tap > tapping the "Lock Screen" icon does it.
The menu gives you access to functions that would otherwise be controlled by pressing physical buttons or moving the device. Here's some of what you can do:
Activate the Accessibility Shortcut
Lock the screen
Adjust the volume
https://support.apple.com/HT202658