Historically, at the federal level, security provided for the judicial branch by the General Services Administration and the U.S. Marshall's Service of the U.S. Justice Department is the main security for judges. This may have changed somewhat, however, due to recent judicial security legislation.
At the state level, there is a position known as a "bailiff" who provides security in the courthouse, often in conjunction with a county sheriff's office. Usually, there is little or not designated security for state court judges outside the courtroom.
Lawyers receive no security in these cases and must fend for themselves. Most law firms have internal policies about how to respond to threats along the lines of - don't allow person X to enter the building, keep shades drawn at times of high alert, and send one person to deal with potential intruders while calling the police and having everyone else flee out the back door if approached by a threatening person. I've been the person dealing with the threatening person a couple of times.
It feels like it would be quite common for individuals with power to
use the threat of violence to influence a judgment in their favor.
This is actually extremely rare and usually handled by ordinary law enforcement rather than by a security detail.