I can only assume you're talking about the recent preliminary hearing of Dr. Conrad Murray and the Michael Jackson case.
The judge's ruling is based on what was presented at the preliminary hearing. They listen to the evidence, then based on a probable cause standard, make a determination if there is sufficient evidence to hold the defendant for trial. Their ruling is typically based on what charges are filed by the prosecution.
The prosecution files whatever charges they think they can prove based on the evidence. They the put on the preliminary hearing and make a motion that the defendant be held for trial ("held to answer") on whatever charges they think they proved up at the preliminary hearing. For example, if they initially charged manslaughter, but during the hearing, they think they proved murder, they can ask the judge to hold the defendant to answer on murder charges. It's up to the judge to rule whether there was enough evidence on the charge requested. If the judge thinks there is, then they can hold the defendant on the higher requested charge.
It works the other way, too. Let's say the DA filed murder charges initially, then put on their evidence at the preliminary hearing, but the judge wasn't convinced the evidence was sufficient. They could refuse to hold the defendant for trial on the charged offense, but could order them held on any lesser offense they think was proven.
Once the judge has ruled, there is a period of time (15 calendar days) between the preliminary hearing and a second arraignment. The DA then files whatever charges they think were proven at the preliminary hearing in a new charging document called an information. In most cases, they file charges that are the same as the judge's ruling. The prosecution can file additional charges - either extra charges, higher charges or lower charges.
From there, the defense can challenge those new charges in a Penal Code section 995 motion. Let's say, for example, that the judge ruled that there wasn't enough evidence for murder, but there was enough for manslaughter. The prosecution disagrees and decides to file murder charges anyway. The defense would then file a 995 motion to challenge those charges. A different judge would then review the transcript of the preliminary hearing and rule on whether or not there was sufficient evidence to support the charges.
The defense can file a 995 motion in any criminal case to challenge the sufficiency of the evidence, even if the charges don't change from the initial charges. The defense can always challenge whether or not the defendant was held to answer based on enough evidence.
To answer the initial question though - can a judge upgrade charges during the trial? No. The decision of what charges to file is up to the DA. From there, the checks and balances of the preliminary hearing and 995 motions can challenge the charges, even before it gets to trial.
Once a case gets to trial, the charges the defendant will face have long since been decided. Of course, at trial, there are lesser included charges to those charged, giving the jury a whole host of options when it comes to deciding the case.
Judges do not increase charges. The district attorney can file an information -- or can amend an information -- to reflect any evidence that was disclosed at the preliminary hearing and that indicates that a previously-uncharged crime may have been committed. He can do this right up until the beginning of trial.