Rewriting internal DNS can be a pain, and I had exactly this problem so I wrote a system to solve it. Yes it uses the third party server to effectively do the redirection for you, but all you need is 2 DNS entries and it will work. Test it out. https://redir301.link/
Use requires the addition of 2 DNS records. One as a pointer to this service, and an additional record as the destination point. DNS RFCs prevent a CNAME record also having an associated TXT record so one needs to improvise.
To use, you need to set up the subomain to point to redir301.link. (don't forget the DOT at the end!)
subdomain.foo.com 14400 IN CNAME redir301.link.
Then set the associated TXT record to the destination URL. TTL should be set to a MINIMUM of 300 (5 min).
301.subdomain.foo.com 14400 IN TXT "<destination URL>"
Destination URL can be any URL but the sub-subdomain needs to be 301 otherwise it will fail.