Sun, 28, was accused of smashing the vials containing his blood after a row with a team of official drug-testers at his home in September 2018.
The Court of Arbitration ruled on Friday that "the athlete failed to establish that he had a compelling justification to destroy his sample collection containers and forego the doping control".
Sun, who had earlier served a three-month ban for an earlier offence, had argued he smashed the vials because he did not believe the testers were properly accredited or qualified.
He was cleared initially following an investigation, and went on to defeat Britain's Duncan Scott and Australia's Mack Horton in the World Aquatics Championships in South Korea in July 2019.
He famously clashed with Scott during a medal ceremony in which the third-placing Scott refused to take a photo with the first-place Sun.
Sun had walked off the stage taunting Scott, saying: "You're a loser, I'm a winner, yes."
But the Court of Arbitration for Sport (CAS) upheld the World Anti-Doping Agency's (WADA) appeal on Friday to overturn the decision to clear him of the doping offence.
The decision means Sun will not be allowed to defend his 200 metres freestyle title at the Olympic Games in Tokyo and effectively ends his swimming career.
Duncan Scott put out a statement following the ruling, saying he respected the CAS decision.
"I believe in clean sport and a level playing field for all athletes and I trust in CAS and WADA to uphold these values," he said.
The CAS ruling threw out the argument from Sun that he did not believe the drug-testers to be verified.
"As the Panel noted, it is one thing, having provided a blood sample, to question the accreditation of the testing personnel while keeping the intact samples in the possession of the testing authorities; it is quite another thing, after lengthy exchanges and warnings as to the consequences, to act in such a way that results in destroying the sample containers, thereby eliminating any chance of testing the sample at a later stage," the ruling read.