Contempt is a curious creature of the courts. This inherent authority empowers judges to take all manner of actions against parties, including incarceration. Indeed, this power is so broad that a federal judge can order the prosecution of a party, even if the Department of Justice declines to bring the case. Consider Federal Rule of Criminal Procedure 42:
The court must request that the contempt be prosecuted by an attorney for the government, unless the interest of justice requires the appointment of another attorney. If the government declines the request, the court must appoint another attorney to prosecute the contempt.
This language is not optional, it is mandatory. The Court "must" make this request of DOJ, or in the alternative, "must" appoint another prosecutor. I suspect it is fairly rare that the government declines to bring a contempt prosecution. One such recent case arose in South Dakota. A district court judge held a United States Marshal in contempt of court, and, unsurprisingly, DOJ declined to prosecute another member of the federal government. As a result, the court appointed its own prosecutor, then promptly recused from the case. That recusal at least eliminated an inherent conflict of interest. I don't think a judge can remain a neutral arbiter if he appointed the prosecutor. Ultimately, the newly-appointed judge dismissed the contempt case. But in another, far-more-high-profile case, a federal judge in Manhattan chose a different path.