They can ask you but you don’t have to show it to them.
Why would I not show it to them, or even resent them asking? I know full well why they have to do it. It’s not an accusation that I’ve stolen anything, it’s done because many other people do.
The cost of shoplifting eventually affects me, anyway. The store is wise to try and protect itself.