You mean like, on the street, in a crowd of people? Probably not a good idea.
If you mean in your own apartment or house, which is located in an urban environment, then unless there is a law prohibitting such a practice, which I'm not currently aware of, then it is legal. Of course, a landlord might prohibit it on their property, but even that's not illegal, just going to piss them off, and possibly give them cause to break the lease, if they in writing forbid you from doing such when you signed the lease.