Using the same method as in the answer you added,
I simply adjusted to PyQt5 and guessed base on the example that this will work.
It seems this works only in projects which have already been saved (for me it crashed the untitled project i was in) but works pretty well.
from PyQt5.QtCore import QSettings
QgsProject.instance().writeEntry( "ScaleBar", "/Color" , "#ff9e00" ); #Can also be rgba 255,158,0,255
QgsProject.instance().writeEntry( "ScaleBar", "/MarginH" , 0 );
QgsProject.instance().writeEntry( "ScaleBar", "/MarginV" , 0 );
QgsProject.instance().writeEntry( "ScaleBar", "/MarginUnit" , "MM" );
QgsProject.instance().writeEntry( "ScaleBar", "/Style" , 3 ); # 0 Tick Down, 1 Tick Up, 2 Bar, 3 Box,
QgsProject.instance().writeEntry( "ScaleBar", "/Placement" , 0 ); # Bottom Left
QgsProject.instance().writeEntry( "ScaleBar", "/PreferredSize" , 30 );
QgsProject.instance().writeEntry( "ScaleBar", "/Enabled" , True );
#Save Project
QgsProject.instance().write()
extent = iface.mapCanvas().extent()
#Reload project
def set_extent():
iface.mapCanvas().setExtent(extent)
iface.projectRead.disconnect(set_extent)
print('Loaded using new copyright label')
filename = QgsProject.instance().fileName()
iface.projectRead.connect(set_extent)
iface.addProject(filename)
If you want to get the other options you can save your project as Qgs and find all the options there inside the ScaleBar node.
The font properties are defined within an inner TextFormat node.

qgis.gui.QgisInterfaceobject. You can try using that. – Dror Bogin Oct 26 '20 at 11:24