No. But they definitely can reside inside the cracks and crevices of stones.
Is it possible that a lizard (or in some cases, a beetle) lives inside
a rock for thousands of years when that stone got formed?
No. The longest living vertebrate is the Galapagos Tortoise which only lives for 100-200 years. And the oldest living insect is the Queen of Termites which can live about 50 years. Both of these are far from being "thousands" of years old.
Seeing as this stands so far outside the realm of theoretical possibilities I would put this in the category of logical fallacy.
But some microbes have been known to live for thousands of years in solid materials...
"Being at my seat near the village of Meudon, and overlooking a
quarryman whom I had sent to break some very large and hard stones, in
the middle of one we found a huge toad, full of life and without any
visible aperture by which it could get there. The laborer told me it
was not the first time he had met with a toad and the like creatures
within huge blocks of stone."
If this were true it would be a major scientific discovery. This is likely a worker hoaxing his gullible boss. If the worker said that "it was not the first time he had met with a toad and the like creatures within huge blocks of stone", then this would indicate that the event is reproducible. In which case it might be able to stand up to the scientific method, and have the ability to produce real scientific merit.
The soldier pried a stone slab away from the quarry face when he saw
"in a pocket in the rock a large toad and beside it a lizard at least
nine inches long. Both these animals were alive, and the amazing thing
was that the cavity they were in was at least 20 feet from the top of
the quarry face
This is probably due to something called memory distortion. Which can easily and often does lead people to recall events inaccurately. The rock could have been loose and had a crevice on one side that the person didn't notice, which the animals were hiding in. Then after he pried the rock away he convinced himself they were sealed in there.
See the "The Hindsight Bias"