yes if the plant is indoor on a photoperiod then interupted dark cycles WILL cause enough confusion for the plant to try and reproduce to survive. its not that the plant is a hermie, all fems will do it if light stressed /heat stressed during flower.
a herm plant will present both male and female flowers throughout most of the flower period.
fems that are light stressed that produce "male flowers" will only have XX chromosomes in the pollen not XY thus fem seeds
now for outdoor plants :
if the plant is subjected to a light source during the night and that light source has been there every night throughout the season then unlikely that it will affect the flowering period/light stress the plant to cause "male flowers"...just like the moon does not affect them.
but if this light source is irregular when it comes on/off or has become a new addition during the night ie: a neighbour installed a sensor light etc then yes chances are it will have an effect on "male" flowers .
i learnt this from an old ed rosenthal/mel frank publication years back