Staying overnight at Petra
Staying overnight at Petra is forbidden but possible.
Obviously, you can camp in a remote area, like the
top of Umm-Biyara. It's almost for sure
no body will find you.
But if you are not that adventurous, here's what you can do:
Wander around the ruin after dark (6:00pm in winter).
You will soon run into a local Bedouin. Some of them
will offer you a tea. Be prepared to pay 1D for the
tea. Then some will offer you to stay overnight at their
cave/souvenir shop. I'm not sure about the price, it's
probably around US$15.