The crime of impersonating a Starfleet officer was the act of falsely presenting oneself as a Starfleet officer and using this pretense to falsely act in the name of the service. A person committed this offense by such actions as wearing a Starfleet uniform to deceive others into believing they were a Starfleet officer, issuing orders to legitimate Starfleet personnel, or falsely conducting activities in the name of Starfleet.
In 2368, a Satarran using the alias of Kieran MacDuff posed as the executive officer of the USS Enterprise-D as part of an attempt to use the starship to destroy the Lysian Central Command. (TNG: "Conundrum")
In 2370, William Samuels impersonated a Starfleet officer on Deep Space 9 in order for him to destroy the Cardassian freighter the Bok'Nor, which was docked at the station, for the Maquis. (DS9: "The Maquis, Part I")
In 2371, The Doctor experienced a delusion due to a kinoplasmic radiation surge. Told by Reginald Barclay that he was actually Lewis Zimmerman, and USS Voyager was a holographic simulation, he accused Barclay of being an alien impersonating a Starfleet officer. (VOY: "Projections")
In 2375, the genetically engineered Humans Jack, Patrick, and Lauren were all charged with impersonating Starfleet officers after they brought Sarina Douglas to Deep Space 9, during which they wore Starfleet uniforms and ordered others such as Nog to contact Julian Bashir. Patrick was dressed as an admiral, Jack as an operations officer, and Lauren as a science officer. Whenever they were questioned about their activities, Patrick answered "That's a stupid question!", which succeeded in continuing the deception. Because they were only trying to get assistance for Sarina, Bashir convinced Benjamin Sisko to ask that the charges be dropped. (DS9: "Chrysalis")
The following year, the crew of the USS Voyager discovered con artists Dala, Mobar, and Zar impersonating Voyager officers Kathryn Janeway, Tuvok, and Chakotay, respectively. They were able to do so after deceiving Neelix and Tom Paris into allowing them onto the Delta Flyer where they stole their database and acquired the knowledge of Starfleet within it. They then used this information to impersonate the aforementioned officers and swindle unsuspecting victims. After being captured by the Voyager crew, they were turned over to local authorities for prosecution. (VOY: "Live Fast and Prosper")