It is legal if the lease you signed either specifically prohibits overnight guests or else gives the company the right to put out rules like this: leases are contracts, and their terms are enforceable. Thus, you may be held to whatever terms you agreed to in signing the lease. On the other hand, since leases are contracts, neither party may change or add to the terms without the other's consent or agreement; therefore, if your lease neither prohibits guests nor gives the rental company the power to put forward a rule like this, the rental company cannot prevent you from having overnight guests.