Impersonate:
to assume the character or appearance of; pretend to be; to act or play the part of; (Archaic.) to represent in personal or bodily form; personify.
Less common is
Personate:
to act or portray; to assume the character or appearance of; personify.
Impersonate is often used in a negative sense where deception is involved, but this definition shows that personate can be used the same way in legal terms.
UPDATE
Another word that might come across is immersion. The linked article is somewhat convoluted (which is no surprise given that it is posted under the heading "The Gaming Philosopher"), but the general meaning is here:
Fictional identification with a character (immersion) is helped by mechanics that give total authorship over the character's beliefs, desires, decisions and so forth to one player.
So a person having an immersion experience has total control over the traits of the character they are imagining or pretending to be.
UPDATE 2
I have come across another term that is more about one's state of mind (imagination) rather than ones actions (role-playing).
Escapism
The avoidance of reality by absorption of the mind in entertainment or
in an imaginative situation, activity, etc.
Escapism is more a state-of-mind than an action, as it attests to the mental state that may drive one to actually escape their current circumstances. It begins with the visualization of alternative conditions. These conditions might be the environment (a vacation escape usually begins with the visualization of that other place), but one can also turn to an alternative identity.
From this article on the subject, the writer discusses escapism and identity in both positive and (clinically) negative terms. Here is an excerpt:
From a psychology perspective, Baumeister (1991) commented that
individuals may be trying to escape their current ideas of “self”. He
also suggested that escape may be temporarily achieved by “shrinking”
down the self to its bare minimum. … The feeling of flow experience
has been described as an enjoyable and focused concentration in which
one experiences a loss of self-consciousness (Csikszentmihalyi, 1990).
Hence, being in flow means temporarily escaping one’s ideas of self.
From a psychology perspective, Baumeister (1991) commented that
individuals may be trying to escape their current ideas of “self”. He
also suggested that escape may be temporarily achieved by “shrinking”
down the self to its bare minimum. … being in flow means temporarily
escaping one’s ideas of self.
It’s not a great leap to say that imagining that one is someone else is a form of escapism. This would be the case whether it's as a short-term entertaining diversion or as a short- or long-term means to avoid reality in one's personal life.
Since escapism covers more than imagining about one's identity, I suggest a phrase such as identity escapism might meet your needs.