That’s a question often asked by a client. Moreover, it depends. The answer depends on where you are. Well, that answer is simple: are you in state court or federal court?
If you are in federal court removing a judge is next to impossible. The judge must show bias or has some interest (financial usually) in the outcome. For instance, your case is assigned by “lot” to a federal judge that hates defendants – what can you do? You have your attorney file a “motion to recuse the judge” based on bias or interest. The case is sent to another judge who then makes a finding. Other than that you can appeal after the motion is over.
In state court, the answer is more straightforward. At the outset of your case being assigned to a judge, you can disqualify the judge by filing a P.C. 170.6. However, it has to be timely, once the court begins to hear the case, say after the first appearance, you may be out of luck to disqualify the judge. It has to be at the beginning of the criminal case and not at some other time.