Hey, I think the best way of approaching that is through a compiler plugin. If you are only modifying the implementation of toString, you don't have to change much, mostly generating new method body through IR.
I did a similar in implementation thing for an old backend, write-up here:
https://medium.com/bumble-tech/fixing-serialization-of-kotlin-objects-once-and-for-all-95886fddba7a
The example repo should also contain implementation for the new IR backend, albeit with an older version of compiler (a thing or two have changed since ;))