Can I safely steal from shops while invisible?

No, if you attempt to enter a shop while invisible, the shopkeeper will block the entrance with the message

[name] detects your presence. "Invisible customers are not welcome!"

If you put on the ring while already inside the shop, the shopkeeper will refuse to move even if you pay for all of your items.

You can exploit this behavior to kill the shopkeeper if you have sufficient ranged weapons and some kind of method to counter their wand of striking and possibly wand of magic missile (note that reflection will not block the wand of striking!), but this will come with murder penalities if you're not chaotic.

A character with intrinsic invisibility can still circumvent this by wearing a mummy wrapping, which will cancel the effects of the invisibility.