This changes the default. It does not affect the current setting if you have already switched to the Segment Editor before or you loaded a scene that contained a segment editor node.
You can change the masking settings in all the existing segment editor nodes like this:
for segmentEditorNode in slicer.util.getNodesByClass('vtkMRMLSegmentEditorNode'):
segmentEditorNode.SetOverwriteMode(slicer.vtkMRMLSegmentEditorNode.OverwriteVisibleSegments)