OK, first. . . yes in the general case. The owner of a property may limit the "license" granted to visitors in any (lawful) way the owner chooses, and violation of those limits is trespass.
The operative word here is "lawful." There are ways that, by law, an owner may not limit the license...