First, you need to research Deniable Ops (Military tree);
Next, purchase a ship from the marketplace;
You can turn any fleet with only mercenary (bought) ships and without a hero into Privateers;
Then you need to have an alliance with another civilisation and they can't have a non-aggression treaty with the Pirate League;
After that, just use the Privateers to attack their ship or system.