Yes you may rename them
I once traded some Pokemon to my friend. 2 months later he traded them back to me since he got good Pokemon of his own. Guess what it said on my game when I got my Pokemon back:
'Welcome back serperior!'
So the game knows that it was originally your Pokemon. So you can rename them and do everything else with them as if they were always with you.