You can use (or write a similar function to) the slicer.util.setToolbarsVisible
function to show/hide toolbars.
You can customize everything about how the application looks or behaves. Check out the Slicer Script Repository for more examples and the Slicer Custom Application Template if you want to create a proper custom application. If you have any specific question that is not answered in the script repository, here on the forum, and you have trouble getting useful answers from AI copilots then feel free to keep asking here (each independent question in a new topic, so that others can easily find the questions/answers later).
I am just curious - why do you want to hide the Python icon? You don’t want the user to be able to show the Python console? Or you don’t want the user to be able to hide the Python console? Even if you hide the icon, there are still ways for users to make Slicer display a Python console (e.g., a developer who knows Slicer could specify a command that makes the application display the Python console, could add a Slicer module that registers a new keyboard shortcut for this or adds a button to the module’s GUI, …), so depending on what exactly you want to achieve, there may be better way to do that than hiding a toolbar button.