Expand / Reduce, lvl 2 PHB p.237
Reduce. The size of the lens is reduced by half in all dimensions, and its weight is reduced to one eighth of normal. This reduction decreases its size in a category, from Medium to Small, for example. Until the spell ends, the target also has disadvantages in the Force tests and in the Force save shots. The target's weapons are also reduced to fit their new size. While these weapons are reduced, the target's attacks with them inflict 1d4 less damage (this can not reduce the damage below 1).
So RAW there without orientation as to what happens, so it corresponds to the DM to adjudicate. As a guide, I would like to see spells that damage the target if they somehow interact negatively with an object when a spell is completed.
Meld into Stone, lvl 3 PHB p.259
The minor physical damage to the stone does not harm you, but its partial destruction or a change in its shape (as long as you no longer fit in it) expels you and inflicts a 6d6 damage.
Etherealness, lvl 7 PHB p.238
When the spell ends, it immediately returns to the plane from which it originated in the place it currently occupies. If you occupy the same place as a solid object or a creature when this happens, you will immediately deviate to the closest space you can occupy and will receive a force damage equal to twice as many feet as you move.
Dimension Door, lvl 4, PHB p.233
If you arrive at a place already occupied by an object or a creature, you and any creature that traveled with you will receive 4d6 of force damage, and the spell will not teleport you.
Therefore, being forcibly ejected from a block of stone at level 3 deals damage of 6d6, being displaced 10 due to an object on the path after the plane change at level 7 makes 20 damage by force (approximately the average of 6d6), and the backward rebound from a teleportation effect with an object in the way a level 4 makes 4d6.
It may not be so obvious, but this gives an approximate scale. As DM, it would impose the following: if the reduced person were placed in a small hole in a block of stone and the hole in the form of a closed stone, encased in the stone properly, it seems appropriate that the maximum damage to the spell be a 6d6 onslaught as they came out of the stone. I would impose the same for a piece of metal. A bottle can be cut 1d6 when the bottle is broken, 2d6 for a wooden box or a thick glass bottle or a metal jar. An iron cage or a metal chest could be 3d6. A stone sarcophagus could 4d6 me. An iron coffin could be 5d6.
A better way to do this is probably doing 2d6 damage per blow to the creature when it explodes out of the container. This is simple and related to the spell level.
All very subjective and nothing RAW, but for me these suggestions seem in scale with other spell effects. If you think this suggestion does too little harm, I always try to remember that science and / or common sense do not have a real place here as it is. magical that "explains" what happens, and it's also just a second-level spell, so the magic is relatively weak. After all, if you could kill level 10 fighters in this way, it would be THE Spell, along with a metal casket on wheels.