Set layer visibility using QgsMapCanvasLayer in QGIS 3?
Just for the record, I had to turn to a different class and member function to set the visibility of a layer lyr
in QGIS 3:
QgsProject.instance().layerTreeRoot().findLayer(lyr.id()).setItemVisibilityChecked(False)
This is based on searching/researching the breaking change page:
QgsLayerTreeGroup
setVisible() is replaced by QgsLayerTreeNode::setItemVisibilityChecked()
There might be other ways, but this is what worked for me.