I would imagine that most places that take cash only advertise it when you walk in. You know going in that you need plastic. If there's no notification, then there's a reason to argue.
"Places that take cash only" would be exactly the opposite situation. We're discussing cases where the merchant only accepts electronic payment—no cash. And it doesn't matter whether they post a sign saying "credit card only, no cash"—if a debt exists, you can pay it with legal tender. Even if they had your signature on a written contract, to refuse your offer to pay in full in legal tender would amount to forgiving the debt. They can blacklist you for it, but they can't legally claim that you still owe them anything. If a merchant doesn't want to deal with cash at all their only option is to avoid giving customers anything on credit, even short-term credit such as one incurs at a restaurant.
That is what legal tender is: a payment method of last resort which can be used to settle any debt, regardless of any prior agreement you may have made to pay by a different method.
That is the legal situation, more or less. As for the morality of the subject, I perceive legal tender as a bit of a grey area: I disagree with the current political methods but also think that the situation would not be significantly different if limited to legitimate (voluntary) means. On the one hand, legal tender laws are being imposed on the merchant by force, and a customer or party to a contract who agreed to pay in one form should not attempt to escape that voluntarily accepted obligation—I consider that contract-breaking and tantamount to theft. On the other hand, it would not be unreasonable for a court charged with resolving such disputes to impose the condition that the plaintiff must agree to accept some standard form of compensation as a condition of receiving the court's assistance, rather than the specific property in dispute. Some cases would be impossible to resolve without that constraint; the defendant may not even have the disputed property. On the other other hand, the government's courts claim a monopoly on arbitrating such disputes, which means any conditions they impose are at least partly based on force. If you don't agree to their conditions you have nowhere else to turn.