WASHINGTON—A federal appeals court on Friday reinstated the conviction of a Pennsylvania man for making threats on Facebook, the last twist in a closely watched case that made a 2015 trip to the Supreme Court.

The high court last year had thrown out the 2011 conviction of Anthony Elonis for making threats—in the form of rap-music lyrics—on the social media site against his estranged wife, local schools and law-enforcement officials.

In...