Oooh, that’s a great question. As an otter that often hunts at night, I have often asked myself the same thing. Would be great to have a little light of my own in the murky November waters.
I once found an old chemistry book by the side of a stream, and I read something about Luciferase in it. Sounded scary.
The light is produce by a reaction between oxygen, ATP, a small molecule called luciferin and an enzyme (luciferase). Most of the energy comes out as light rather than heat, so if you hold a glowing glow-worm on your hand it feels completely cold.