The code snippet below is part of my Python tool which makes this easy.
In my code, this is run within a loop for multiple layers and it very slow, as it has to wait for ArcGIS Pro to add each layer to the map and then remove it again. ArcGIS Pro is the most unresponsive application I've used on any OS anywhere anytime ever (can you tell it annoys me? A lot.).
Before this snippet, the logic gets a list of all featutre classes in the new Data Source and for each of the old feature classes to be changed, it checks the list to make sure that there is one with a matching name in the new Data Source to use as 'fcNew'. If there is not, then my particular tool will output a warning, and depending on another parameter in the tool, may also remove the layer if its data source could not be updated (due to no matching FC in the new DS).
fcNew = os.path.join(newDS, fcName)
tmpLayer = map.addDataFromPath(fcNew)
newProperties = tmpLayer.connectionProperties
map.removeLayer(tmpLayer)
## arcpy.AddMessage("OLD connection properties:\n{}".format(layer.connectionProperties))
layer.updateConnectionProperties(layer.connectionProperties, newProperties)
## arcpy.AddMessage("NEW connection properties:\n{}".format(layer.connectionProperties))