I had trouble getting Wireguard to connect when using Tasker on another phone. Turning on a tunnel in a task only worked intermittently. If you're experiencing the same thing the work around is adding a step to start WG and then connecting the tunnel, but if I remember correctly I had to include a step to return to the previous app so I wouldn't end up with the WG UI left on the screen.
I do have one task shared on taskernet.com that may be of use. Go to https://taskernet.com/?public and deselect the "Basics" tag at the top, then search for "wireguard". Look for Wireguard Autoconnect. It's designed to connect a WG tunnel, then run an app and maintain the tunnel as long as the app is still on the screen. It drops the tunnel if you switch to another app or the launcher. Someone else has uploaded one that connects WG when not on your home SSID, but doing that requires location to be left on all the time, something which I avoid.
Would have no problem sharing my other configs but they've become too complex to do that easily. Everything's interconnected and nested with tasks setting and clearing multiple variables and then calling other tasks based on events and those variables. I'm no expert but am glad to help if you have questions and am on Lemmy often. DM me.