I tried scaling the gizmo down when i scale the layer up (and vice versa), like this:
Set Layer 1 scale to LayerScale(1)+0.002
Set Gizmo scale to LayerScale(1)-0.002
but unfortunately it doesn't work as expected. It keeps scaling up with the layer, just with a slower rate.
With this method though the position is maintained, so I don't need to do anything.
The other method is to set the scale rate of the layer to zero (which solves the scaling problem), but messes up its position. In this case I can do as you said: keep track of the gizmo's X and Y and position it. The problem is that the 2 layers (one scaled the other not) seem to have different coordinates after scaling. I'm guessing I have to use CanvasToLayer or LayerToCanvas but I can't really grasp what's happening