Building on top of Yerke's answer: modgraphviz from the experimental package can be used to convert the output into a Graphviz-readable format.
go install golang.org/x/exp/cmd/modgraphviz@latest
go mod graph | modgraphviz
go mod graph | grep -vE 'cloud.google.com|golang.org|google.golang.org' | modgraphviz | dot -Tpng -o graph.png