The US Court of Appeals for the District of Columbia Circuit affirmed the federal trial judge's decision to hold Twitter, now known as X, in contempt and fine it $350,000.
The ruling said that Twitter had raised First Amendment concerns about a nondisclosure order issued over the warrant, as the company wanted to notify Trump about it.
"Under the circumstances, the court did not abuse its discretion when it ultimately held Twitter in contempt and imposed a $350,000 sanction," the ruling said.
Trump, in a post on his social media site Truth Social, said the Justice Department "secretly attacked my Twitter account, making it a point not to let me know about this major 'hit' on my civil rights."
Prosecutors will often ask judges that targets of subpoenas issued in criminal probes not be notified in order to protect their investigations, a practice the appeals court cited in Wednesday's ruling.
A spokesperson for Smith declined comment and a spokesperson for X did not immediately respond to a request for comment.
Wednesday's opinion did not identify which judge held Twitter in contempt.
While Trump's tweets are publicly viewable, the company also holds non-public information on accounts like direct messages, drafts of tweets, location data and the type of device used to send tweets.
The opinion said the warrant was related to Smith's investigation into the events surrounding the January 6, 2021, siege on the US Capitol by supporters of Trump while he was still president.
Republican Trump last week pleaded not guilty to an indictment that charged him with plotting to overturn his November 2020 election loss to Democrat Joe Biden.
Trump is the front-runner for the Republican 2024 presidential nomination.