Yes, if it’s outlined in the contract you both signed at the start of the rental agreement. In some cases, they may only charge a few months' rent; in others, it can be the full remaining cost of your lease. Read your rental agreement to see what you agreed to.