How can I safely connect a subpanel in a detached garage to the main with a 3-wire connection?
If you are in a situation where a 3 wire feeder can be used, you will need to bond the grounded (neutral) conductor to a proper grounding electrode system in the detached building. So yes, the diagram is correct.

NOTE: The grounding electrode system, may be required to be made up of more than a single ground rod.