Not possible with Shader Graph unfortunately. This requires a multi-pass shader, or possible two materials with one writing to Z and not color, neither of which are possible with Shader Graph. Multi-pass shaders aren’t currently possible in SRPs in general.
HDRP/lit should expose a ‘depth prepass’ option on the master node. Unfortunately it seems broken at the moment, on 2019.2.0b3 / HDRP 6.7.1 at least. I submitted a bug for it.