I'm renting a room from a friend and she wants me to sign a lease agreement with her. The weird thing is that she has told me that she has signed a previous lease agreement that stipulates that she will not sublease the apartment. If I did sign a contract with her, would it be legal and binding?
If two parties form a contract (assumed to be legal in every way) that requires one or both parties not to form similar contracts with any other party, this is an exclusivity arrangement. They are extremely common in agreements involving tenancy and copyright, and are not unknown in agreements involving employment and trade/service provision.
Forming the disallowed contract would be a breach of contract by whichever party was disallowed and yet did so. While not an offence per se in most jurisdictions, it may indirectly lead to an offence under some other law (such as tenancy, copyright, employment or commercial law) and may directly lead to a lawsuit by the party that did not breach the contract.
That party could seek to cancel the offending contract (a specific performance which may not be possible) or to cancel the breached contract by reason of repudiation, or to obtain compensation for damage caused by the breach, or some combination of these.
It may be that limiting subleases is not a legal term of the original contract, or that adding you to the existing lease is a legitimate action (it's as if you were part of the same contract, with all right and responsibility the same). It's also quite possible that your lease agreement with the friend is not acceptable under their own lease agreement. Check your jurisdiction tenancy law and/or see a qualified lawyer in it.