Background. Phenotypic modulation was shown to be related to the pathological mechanism of diabetes mellitus erectile dysfunction (DMED), and excessive expression of YAP1 was measured in the cavernous tissues of rats with DMED. Objectives. This investigation was performed to explore the efficiency and mechanism of gene therapy through the knockdown of YAP1 in the field of ED treatment. Materials and Methods. Corpus cavernosum smooth muscle cells were obtained and cultivated in vitro employing the explant technique. EdU, CCK-8, and collagen gel lattice contraction assays were subsequently performed to assess cell proliferation and contractility, which indicate smooth muscle phenotypes. Results. Initially, overexpression of YAP1 enhanced the proliferation and expression of YAP1 and osteopontin (OPN) while reducing cell contractility and the expression of myocardin, α-SMA, and calpontin, which is consistent with phenotypic modulation. Moreover, knocking down YAP1 resulted in the opposite effects, and the blockade of myocardin attenuated the reversal of phenotypic transformation. Then, 45 screened DMED rats were randomly divided into three equal groups, named streptozotocin (STZ)-induced DMED with intracavernosal injection of Ad-myocardin (DMED + myocardin), DMED with lenti-shYAP1 (DMED + shYAP1) and DMED with PBS (DMED + PBS), and 10 rats were in the negative control group. Staining with H&E and Masson’s trichrome, immunochemistry, and determination of the ratio of the intracavernosal pressure/mean arterial pressure were performed to evaluate penile erection and histological changes. Western blotting was conducted to determine the molecular protein expression levels. In vivo, similar to myocardin overexpression, YAP1 inhibition rescued erectile function, repaired morphology, and maintained the contractile phenotype of smooth muscle tissues 14 days after treatment. Discussion and Conclusion. In conclusion, our study demonstrated the validity of gene therapy by downregulating excessive YAP1 expression to ameliorate ED in diabetic rats, and the ability of YAP1 inhibition to reverse phenotypic modulation was mediated through interaction with myocardin.