You can refuse, but then they can do what they do. It depends on the situation what happens next.
I think it’s a bit rude, and a weird/unwise store policy, with the possible semi-exception of Costco, where you’ve got a bunch of people steadily leaving with large carts full of stuff, some of it valuable. There, it makes more sense to me as a cooperative effort to enable lots of people to buy lots of things . . . however, even there, especially before they added self-check-out (where they’ve recently started adding a THIRD ID checkpoint!), I think it could be handled differently. The problem is, they’ve arranged their stores so that there’s typically a food court, automotive shop, and returns center, oh, and restrooms, in a large area AFTER the checkouts.
(That is, there’s no one whose job is to make sure no one subtly wanders past the checkouts to the other areas with some stuff, which is a large area to cover, so it does kinda make sense with that layout, to check at the door.)
If checkouts led more directly to an exit, or if some other security system were used, then you could probably avoid the second set of inspection at the door.
I only distinctly remember refusing once, many years ago, at COMP USA. COMP USA had particularly annoyed me in other details regarding a purchase (and return/refund or something) involving a large computer screen/monitor, and they had recently added an annoying policy of having a rude idiotic dude hanging around in the exit area demanding receipts of everyone. This COMP USA did NOT have multiple people leaving at once – it seemed to me to be clearly a thoughtless silly policy. It seemed especially silly one day as I was leaving with one enormous monitor in my cart, that there was no possible way I had just taken without already having to deal with multiple other staff inside, so I took pleasure in telling the poor guy stuck with that receipt-checking role, that no, I wouldn’t show him my receipt. I also got to be amused by hearing him try to invent things to say on the spot, about how I really had to stop and show him a receipt. No, I didn’t. Bye.
I also (but only indistinctly) remember some stores where I ignored requests from staff to talk to them as I left the store. I did have a receipt, but wasn’t going to bother to talk to them unless they came right over to me where I couldn’t ignore them.