There may be an way to do it with BPY code that I am unaware of.

On the other hand, you can toggle the viewport 3D gizmo visibility by clicking the <kbd>arrow icon</kbd> in the screenshot, then clicking the option <kbd>Navigate</kbd>.

There is also the shortcut <kbd>CTRL + ~</kbd> to toggle the gizmo visibility.

[![enter image description here][1]][1]


  [1]: https://i.sstatic.net/8wApc.jpg