This needs some simple hardware trigger, that can be queried by bootloader, but specific wnough so it won’t trigger in your pocket. If buttons are unavailable, I can propose several idead:
Cover the proximity sensor 10 times per second. Requires good motor skills.
Shine separated red, green, and blue lasers into three of the phone cameras. You’ll need a box with three different-colored LEDs to cover cameras module.
There is a low-speed data channel in wireless chargers. Just add the button to the charger instead of the phone.
Put your phone at exactly 2.5G of acceleration. Accelerometer is easy to use even from the bootloader, however you will need to put your phone in a centrifuge and reboot it while it’s rotating.
An option ‘Reboot into recovery’ in system settings, duh. Won’t help if your ROM fails to boot.