From Android 12 custom roms are failing Safety Net by default after rooting with Magisk, so the game won’t run, these steps will allow you to pass the safety net and then spoof location for the game.

Step 1 - Flash latest magisk https://github.com/topjohnwu/Magisk/releases

Step 2 - Go to Magisk settings. Enable Zygisk and Enforce Denylist. Go to configure Denylist and then select Google Play services and select com.google.android.gms (1st) and com.google.android.gms.unstable (3rd from the last). Reboot.

Check Safety Net, should be able to pass both now. Should be able to play the game now.

Step 3 - Flash the latest LSposed module (Zygisk version) using Magisk. Reboot. You should have a notification to open the Lsposed app, it will prompt you to create shortcut on home screen, I would suggest to do that to open it later if needed. https://github.com/LSPosed/LSPosed/releases

Step 4 - Install Hide mock locations module. It should show up inside the LSposed app. https://github.com/ThePieMonster/HideMockLocation

Step 5- Open Hide Mock Location in the LSposed app. Untick hide games (ticked by default) and enable Pokemon Go. Reboot.

Step 6 - Install GPS app of choice. I use Fake GPS by the The App Ninjas on play store. You can combine to use any other app like Pokemod.

If you are not able to pass the Safety Net, then watch this video https://m.youtube.com/watch?v=ss0rq6jNHQM