Toggling on/off icon visibility in GMenu items

You don’t.

Icons in menus should be limited to “objects”, like file types or bookmarks; “actions”, like “Open” or “Copy”, should not have icons.

For objects, you can set an icon to menu items by using attributes in the XML.