Only some viruses work this way, HIV is an example. This is a good article on endogenous retroviruses [1], that is viruses that work by integrating themselves into host DNA (a retrovirus) and made it into germline cells (eggs and sperm, the endogenous part).
And to clarify for those reading this, HIV is not passed from mom to baby via inhereted genome, but as a blood borne illness in pregnancy, during birth, or in breastmilk.
[1] https://www.bbc.com/future/article/20230519-the-viruses-that...