Gastly actually learns substitute via TM, so breeding for it is useless. However, if you really want to know…
Breed gastly and gastly, both knowing substitute (from TM), then the gastly from the egg should know substitute. I'm not an expert in breeding, so if anyone notices this is incorrect, please inform me and I'll change me answer. Hope I helped!
Scroll down for the tms.