... the idea that they could detain based on shopkeeper privilege.
As for Costco, I don't believe they could, but they would probably review their security cameras, see when/which line you purchased in, and identify you that way to revoke your membership. (That's the part I alluded to when I said "it would take a bit of work" to figure out who you are if you refused.)
I don't see how they have the authority to detain you, but it would *possibly* be your last time shopping there.
*edited due to robin's post below