In Pixar's Cars, Doc Hudson is the courtroom judge in Radiator Springs.
Doc serves as the town's respected medical doctor and judge, giving him authority in both everyday life and the legal proceedings involving Lightning McQueen. After Lightning damages the town's road, Doc orders him to repair it rather than simply leave town. That punishment keeps Lightning in Radiator Springs long enough for the film's relationships and revelations to develop.
Doc's identity as a former racing champion is revealed later. He once won three Piston Cups and was known as the Fabulous Hudson Hornet, but a serious crash caused the racing world to discard him. His experience explains both his stern attitude and his unusual insight into Lightning's career.
Sheriff is a separate character who helps enforce the town's rules. Doc's medical role can also cause confusion, but his official position during Lightning's hearing is judge.