Reading the passenger contract, the National Rail Conditions of Travel, I can see no right to use cash (or indeed any specific means of payment).
I think it is a fairly simple case of a private business being able to mandate what it will or will not regard as valid forms of payment. You either agree to it, and travel, or don't, and travel another way.
Unlike some other countries, there is no explicit right to use cash, except in very limited circumstances involving repayment of a debt, and even then, is regulated in terms of denomination(s) of coinage.
Whether there is a contractual obligation on ScotRail to accept cash, e.g. as a franchise holder or as part of an industry scheme, I do not know - but the customer (the end passenger) would have no recourse under this arrangement, even if ScotRail breached a contract or undertaking with a third party, as it would not be unlawful and the passenger would not be a party to the contractual arrangements, (as far as I know the only passenger binding contract is the Conditions of Travel). The industry or franchise holder would have the right to sue ScotRail for the breach, not the passenger - assuming any franchise obligation exists in the first place. Add in the fact that it's the Scottish legal system, I'd say it would be an uphill battle for any passenger!
From a Consumer Rights perspective, as long as this change is publicised, and ScotRail aren't making any misleading claims, e.g. that you can pay by cash, and then dumping you off the train when you try to use it - it's all perfectly above board. It's common for many businesses to be "card only" these days.
Whether it is right, as a society, to permit this, is debatable, and clearly some countries have chosen to protect cash.