Duneit I'm ashamed to say, my first reflex was to think, "how hard is it to turn an LED tail-light on and off?" After all that's what I do.
But then my "adult" inner voice said, "It's 2022...surely some company makes a motion-activated led tail-lamp for bicycles..."
So I Google "
motion activated bicycle tail light"...and I'm glad I did!
Not only are there rear lights that turn on when they sense motion, but there are others that light-up brighter when they sense deceleration so they can function as "stop lamps", and they seem affordable.
For some one like me who's first foray into bike lighting was a tire-driven "bottle" generator in 1971, these moton-activated LEDs are like science fiction.
So my suggestion to you is to look into motion activated tail-lights. You may have to recharge them, but if there are any that take batteries, lithium batteries will last for scores of hours in flashing mode.
Anyway, I, myself am going to look into this, so thanks
Duneit for posting!