It is possible, as demonstrated by a pair of Norwegian vandals. As reported in the Fayetteville Observer:
[The vandals]overlooked a small but crucial detail when they started smashing up a train station elevator: They were inside it.
And the elevator at the Lillestroem Train Station, north of Oslo, appeared to be the vengeful sort, sealing its doors and holding the two for the police.
“Vandalism is always sad, but a lot of people do see the humor in this,” said Ellen Svendsvoll, of the National Rail Administration. “They got what was coming to them.”
The two vandals, identified only as men in their early 20s, went into the elevator late on April 21, waited for the doors to close, and started to kick them, she said. They kicked so hard that the doors jammed, and the elevator stopped, sending an alarm to security guards. The guards tried to lower the elevator, which only jammed the doors more, so they called the police and fire department.
The firemen freed the two suspects, while the police waited outside.