of course you can, inside you get to play Mother nature, however depending on the strain, sometimes they HATE to do that, meaning sometimes the plants will stop growing (having started to flower) and then you have to wait a bit (8-20 days) to wait for it to start veging again, not to mention if you want it to flower right you'll need to wait even longer, until it's growing normal leaves again (5-13 fingers) when they flower the plant reverses the leaf growth, meaning it goes slowly down to just one-leafed buds, if you switch back and forth it cause funky regenerative growth, and that takes time to get it back to where you want it (ready for multiple bud sites).
Assuming you started from seed, i'd advise you to next time, to not switch to 12/12 to sex them, you don't have to, in usually 4-6 weeks after germinating they'll indicate pre-flowers, that way you don't have to go back and forth. The process may not be as bad as that, depending on how far it's actually flowering, if you see just pistils at the junctures of the stems then you are probably ok, but if it's starting to "crown" meaning the top growth at the end of each cola is putting up hairs, then it's going to be a bit before it'll regenerate, and a while before you can switch back to flowering after the veging period.
Make sense?
--another note, I've had some strains that just HATE regenerating, even under 18 hours of light my grapegod did NOT want to regenerate, had to toss it. And that was after it started flowering because I went from constant light to a 6 hr night. evidentally just the 6 hr night was enough to trigger it, and it didn't wanna go back at ALL.