Where does plea bargaining take place?
Plea negotiations almost always occur behind the scenes, rather than in court. Most case negotiations involve the defense attorney and prosecutor speaking one-on-one, whether in the courtroom, in the courthouse halls, in the prosecutor’s office, or on the phone. The lawyers might exchange emails or letters. At some point in negotiations, whether early or late, prosecutors often provide defense attorneys with formal written offers. The prosecution might even ask for a formal offer from the defense.
Additionally, judges regularly hold conferences in their chambers with prosecutors and defense attorneys to try to facilitate agreements without getting directly involved in the negotiations. (See Can the judge advise me whether to plead guilty?) Defendants aren't present at these meetings, at which the judge may or may not play a meaningful role in facilitating a plea deal.
For more on discussions between the government and defense, see Should I meet with the prosecution or police about my case?