This is precisely what this spell is for.
You create a magical restraint to hold a creature that you can see
within range. The target must succeed on a Wisdom saving throw or be
bound by the spell; if it succeeds, it is immune to this spell if you
cast it again. While affected by this spell, the creature doesn't need
to breathe, eat, or drink, and it doesn't age. Divination spells can't
locate or perceive the target.
When you cast the spell, you choose one of the following forms of
Burial. The target is entombed far beneath the earth in a sphere of magical force that is just large enough to contain the target.
Nothing can pass through the sphere, nor can any creature teleport or
use planar travel to get into or out of it...
[other options elided]
Ending the Spell. During the casting of the spell, in any of its versions, you can specify a condition that will cause the spell to end
and release the target. The condition can be as specific or as
elaborate as you choose, but the GM must agree that the condition is
reasonable and has a likelihood of coming to pass. The conditions can
be based on a creature's name, identity, or deity but otherwise must
be based on observable actions or qualities and not based on
intangibles such as level, class, or hit points.
For the literary inspiration, see Jack Vance, The Eyes of the Overworld (1966):
I have decided to apply the Charm of Forlorn Encystment, which
constricts the subject in a pore some forty-five miles below the
surface of the earth...