According to this article:
Prior to 1977 only players who had completed the Stanley Cup playoffs
were eligible. Today, players appearing in 41 regular-season games or
one Stanley Cup Final game for the championship team have their names
engraved on the Cup. The NHL makes exceptions for players who do not
meet the standard because of injury or other extenuating
And according to the NHL:
To have one's name engraved on the Stanley Cup certain requirements
must be met. A player must have at least 41 games played with the club
or one game played in the Stanley Cup Finals. However, in 1994 a
stipulation was added to allow a team to petition the Commissioner for
permission to have players' names put on the Cup if extenuating
circumstances prevented them from being available to play.
However, according to Wikipedia:
The Detroit Red Wings received special permission from the NHL to
inscribe the name of Vladimir Konstantinov, whose career ended after a
car accident on June 13, 1997, on the Stanley Cup after Detroit
defended their title in 1998.
So it appears that player traded away could be added in theory, but probably not in practice.