Several similar effects can already happen in our world.
Carotenemia is a condition cause by excessive consumption of carrots. Several chemicals that give carrots it's orange colour are absorbed by our bodies and because they are fat-soluble they get stored in fatty tissues including outer layer of skin.
It does not exactly give us bioluminescence but it's possible we discover a chemical with similar physical properties that is also Fluorescent or Phosphorescent.
Fluorescence means absorbing high frequency (short wavelength) light and reemiting lower frequency (higher wavelength). The most popular examples are combination of "black light" that is near-UV light source with a material that absorbs it and reemits visible light with disco-violet hue.
This doesn't address your scenario of living organisms in deep caves. But it may seem like it produces light out of nothing on the night side of the planet if you have some source of UV, for example a black hole couple of light years away. In real world such a black hole would also be visible in the regular spectrum so it depends how realistic your universe is.
Phosphorescence is slightly more complicated mechanism of delayed reemision. It could allow your organisms to absorb energy during daylight and slowly emit weak light throughout the night.
For Bioluminescence you need the organism to actually perform the chemical reaction. Microorganisms consumed by the animals are dissolved in the stomach and all their reactions stop. What's probably more realistic is skin infection by bioluminescent fungi.
Fungi are known to infect higher organisms and leech of their matter and energy. They could use some of it to produce light. The problem is that they don't really have an evolutionary reason to do it. The point of bioluminescence for fungi them is to attract insects to consume them. If they are already feeding off your skin they will "want" to attract less attention, not more. Of course you can always ignore it and handwave some symbiotic relationship between the fungi and the animal.