Suppose genome A generates organism oA and genome B generates organism oB. Their phenotypes pA and pB are quite different from each other.
Because genome A and B are not similar enough, organism oA and oB cannot sexually produce viable offspring.
Your question seems to boil down to: "Would it be possible to generate oA/pA and oB/pB from genome A, or a genome similar enough to genome A such that it can still sexually reproduce with genome A?"
So you basically ask whether any genome A could simultaneously produce pA and pB under different external conditions.
Answer: Possibly? The genes involved in the development of organisms typically don't respond to external stimuli but to genes which were active before them (in time). Various genes produce proteins which sense temperature, osmotic pressure or particular chemical species or ions. If those were factored into very early developmental programs, feeding into transcription factors to modify gene expression according to external factors, the same genome could produce drastically different organisms.
To speculate more about this yourself, it would probably help to go away from a code-based understanding of DNA and think more about what it is physically and biologically. Unlike computer programs, DNA "programs" can modify themselves and other programs or the functions they execute.
Biologically, DNA is an information carrier that is transcribed into RNA, which can have functions of its own and/or be translated into proteins. DNA interacts very tightly (physically) with a lot of RNA and protein components, and most things that happen in cells and tissues around them end up modifying the way DNA is handled in some way. Keywords that you could look up are "gene expression", "gene regulation" and "developmental biology".