You want a form of covenants known as vaults. https://blog.casa.io/why-bitcoin-needs-covenants/
Thank you, good sir.