Walmart just lost an ass load of customers.
To answer your question, of course a free market private company can have a more restrictive policy than allowed by law. Walmart doesn’t have to sell guns at all if they don’t want to. They can set any legal policy they want.
But they just lost a few million shoppers.
Can they legally deny gun sales to blacks?
Can they legally deny gun sales to anyone over, say, 50?
No.