They can however place signs visible in their store or write it on their menu that they don't accept $100 bills.
*Fastfood / food trucks are different as you pay before reviving the food.
PS: Though they can ban you from coming back after this. And the payment needs to be reasonable. 10$ for a 9.50$ meal is reasonable a 100$ bill is not.
By ordering, you are implicitly agreeing to that condition.
I actually didn't realize pay-first for cash transactions had become the standard until recently as I made the swap shortly after 'pay at the pump' became common and never really looked back. How does it work? You just estimate how much you need, and the pump cuts off at that point? If you can't hold that much you go back for a refund?
Edit: At least in Europe you usually pump before paying by card/cash in the store. I guess it differs from the US because of the high crime rate there.