Hi
If there is written contract between you and the company , you l have to serve the legal notice period. However, if you wish to resign before it , try to negotiate the notice period. At the last resort, work out the amount payable in lieu of the same.
For elaborate legal remedy, please feel free to reach out.
Thanks