Sure, this happens from time to time.
The most recent case I know of is Dustin Byfuglien, who has switched back and forth between Defenseman and Forward during his career (sometimes within one season). He began as a Defenseman, switched to Forward in 2008, won a cup with Chicago on offense; then was traded to Atlanta, went back to defenseman. He then went back to Forward in 2014, and then in Dec. 2014 swapped back to Defenseman.
Additionally, many players switch in high school or college, particularly as they learn they are more suited to Defenseman. When skating on teams where they are far and away the best skater, they're more likely to play a forward position (where they will presumably have more opportunities to score), but once in a position where they are playing other equivalently skilled players they may learn their body and game is actually suited to defense. Phil Housley is a great example of this.
Finally, there have been a few great players who occasionally played defense due to team needs (for example, if several defenders were injured). Sergei Federov is an example of this; while he played Center throughout his career, he occasionally was used on defense, both during the prime of his career and as he got older.