in short yes
As said above, the simple answer is yes. I have read many articles/books on this and there are time windows when the phenotype sex is determined in a Cannabis plant. During that time females can be stressed into becoming herms or males (influenced by light -kelvin temp and day length-, nutrients in the soil, temperature, humidity, dry/wet soil conditions). Some say that time starts when they sprout, others say the critical period is between the 3rd and 4th weeks of growth. At that time genetic females can become expressed as pheno males, especially if they are stressed. You can also stress post-harvested re-vegging plants to herm and throw male flowers. I have seen that done myself. There are also chemicals that will force males to express themselves as females, and chemicals that will force female plants to express themselves as males. Oddly though, I have yet to get a female clone cutting to flip to being male on me after making hundreds of clones. I would like to... then I could self cross these guys and gals and get seeds.
Regardless of what you see happening physically to the plant, it does not however, change the genetic DNA of that plant. When a female plant produces male flower sacks in early flower on it's lowers or bananas late in flower in the colas, that is still XX. It's sex has not changed.
So no, you can not, technically, alter the sex of a cannabis plant by simple environmental means.
Science, bitch! (just a Breaking Bad reference, for those that get offended easily!)
dank.Frank