A Pokémon's friendship is generally set when the player first obtains it. When a Pokémon is first caught from the
wild, its friendship starts at its base friendship value. Trading a Pokémon also resets its friendship to its base value, unless it is being traded back to its original Trainer in Generation VI or later, in which case it regains the friendship it had before being traded away.
As stated above in this Bulbapedia Article, friendship is completely reset to its default value when a Pokémon trades it. For example, if a Pokémon had a current Friendship Value of 120 and a base Friendship Value of 70 (the latter of which is the case for most Pokémon), it would convert back to 70 after trading. However, starting in Gen 6, the friendship lost from a trade would be regained if it is traded back to the original player.
I Hope I helped! :)
Again, here is the source.