If the written agreement says that you may pay them if you want to leave the company without giving the full notice period, you can do so. They can't change the contract unilaterally. But practically, you can leave by giving them a reasonable period or without giving any notice at all. The only thing they can do is not to give you a service letter as they are not bound to give you one. It is highly unlikely they will take legal action against you for the breach of contract. Actually, three months is quite a long notice period unless you are a C-level employee. Some shitty companies use such long notice periods just to make it harder for the employees to leave but such conditions would be quite difficult to be justified in a court of law.
On the other hand, when you give your resignation, the company can't use you for any serious work, especially, if you are staying just because you are forced to do so because of your contract.