This is approximately what I had in mind. (And I do have a branch somewhere that I forget about that tries to make more of the JIT accessible form Python… Sigh.)
There are some passes that you would want, but it probably is OK to register a pre pass, too, if you prefer the IR at that level.
Now that you mention it, using backend probably is the right way to go.  It is a relatively new part of the JIT (from 2020, in particular newer than the tutorial you linked).
Best regards
Thomas