You can write in a contract whatever you want; it's permitted to sign invalid contracts; but it's the court which decides on the nature of the contract and interprets the will of the parties; the court will disable illegal clauses and replace them by default law.