I am not super sure, but from what I know, you cannot customize what the side button does on the watch, but on the watch ultra, you can customize what the action button does. I do not own an ultra so I couldn't try to set it up directly but the simplest would be to just set the action button to turn on the flashlight at anytime.
https://www.macrumors.com/how-to/apple-watch-customize-action-button/
To turn it on in sleep mode, maybe it is possible in the focus settings. Otherwise maybe an automation in shortcuts. I doubt it it really possible though sorry.