Are you familiar with network namespaces in general? I think the simplest way to do such things is to have a netns that routes through the tunnel and run everything you want to use the tunnel there.
What distribution are you using and does it use systemd?
Hm~, it seems that I've used https://github.com/chutz/mullvad-netns in the past instead of systemd-based netns creation (I don't really recall much about it apart from not having difficulties setting it up).
Now that I've looked for related tooling, I've noticed that https://github.com/jamesmcm/vopono exists. However, I've first heard of it right now, so I have no opinion even on whether it actually works.