You already agree to buy such an ticket (at the "erhöhtes Beförderungsentgelt" price) but there is no way to avoid a criminal law specifically designed for that situation by just changing the content of a contract.
I didn't know that law was so specific.
Sounds quite excessive for such an offence.