The chameleon, :, is the most common and well-known of the shapeshifters in NetHack. They have a 1/6 chance per turn of changing forms: chameleons will change into an animal 2/3 of the time, and a random monster the rest of the time.
Several chameleons are guaranteed to appear on the home level of the Rogue quest.
Chameleons are quite capable of imitating summonable "nasties" such as arch-liches, which can spell death for the unprepared. They should therefore be treated with caution, and dealt with quickly whenever possible. Wearing a ring of protection from shape changers will revert them to their much easier base form, which can only do 8 damage as most by biting.
Eating a chameleon corpse will polymorph carnivorous pets as well, most likely into something useless, which is one of the dangers of leaving carnivorous pets (especially purple worms) near chameleons. It also pays to mind the corpse monsters leave, as eating a chameleon corpse yourself without realizing it will most likely cause a lot of misery, especially for your armor.
A chameleon in the form of a domestic animal can be tamed with the appropriate food, and will remain tame even as it changes forms. Unfortunately, it is very likely to polymorph into a weak form and die, and it cannot be predicted when it will change into something useful. You can improve it, however, by displacing it onto a polytrap while wearing a ring of protection from shape changers.
Because polymorphed monsters return to their natural form upon death, pet chameleons are much more useful; while they can still die in their chameleon form, dying or self-destructing while polymorphed will allow them to shapeshift again eventually, and there is more value in their more powerful forms as a result.
The chameleon is a real-life animal noted for its camouflaging abilities that it uses to hide itself from prey and predators alike. In some fantasy works, such as the Xanth series from which the encyclopedia entry originates, this is extended to full-on shapeshifting.
A small lizard perched on a brown stone. Feeling threatened by
the approach of human beings along the path, it metamorphosed
into a stingray beetle, then into a stench-puffer, then into a
Bink smiled. These conversions weren't real. It had assumed
the forms of obnoxious little monsters, but not their essence.
It could not sting, stink or burn. It was a chameleon, using
its magic to mimic creatures of genuine threat.
Yet as it shifted into the form of a basilisk it glared at him
with such ferocity that Bink's mirth abated. If its malice
could strike him, he would be horribly dead.
[ A Spell for Chameleon, by Piers Anthony ]