Hello Sir,
Firstly, I would like to ask whether you have signed a contract or bond with the company. In case you have then they may ask you to pay them, but that depends upon the terms and conditions of the contract you've signed.
Secondly, if you have not signed any contract then the company can't take any legal action.