Reptiles in enclosures may not have the same level of awareness as mammals or birds, so it's unlikely that they know in a human sense that they are "trapped." However, they can display behaviors indicating discomfort or stress when confined. For example, a reptile may exhibit:
Glass surfing (pacing or rubbing against the walls)
Trying to escape by pushing at the enclosure's barriers
Hiding excessively or becoming lethargic if the environment isn't suitable.
These behaviors suggest that the reptile may be responding to unmet needs, like lack of space, improper temperature or humidity, or insufficient enrichment. So while they may not understand the concept of being "trapped," they are sensitive to their environment and can react to confinement when it isn't ideal for their well-being.