To quote the PS help room FAQ on this topic:
"Custom avatars are given to Global Staff members, contributors (coders and spriters) to Pokemon Showdown, and Smogon badgeholders at the discretion of Zarel. They are also sometimes given out as rewards for major events such as PSPL (Pokemon Showdown Premier League)."