If you are not a member, you have not consented to it, and the transfer of ownership already occurred at the point of sale. So you can walk past the exit line and right out the doors. Attempting to hold you in the store against your will could be considered kidnapping.
Some states have https://en.wikipedia.org/wiki/Shopkeeper's_privilege
But that still requires cause to believe you stole something, and as far as I understand it, declining to be searched on its own doesn’t provide cause for that.
Costco has a membership agreement where you consent to being searched, Walmart does not.
They get away with it by training the vast majority to consent for no particular reason.
The worst that's ever happened was that I once had a Best Buy guard yell at me and start trying to chase me out into the parking lot, but I just ignored him and he eventually gave up and went back. Flaunting fake authority like that makes me very happy for some reason.