A Thai judge shot himself in the chest in a court in an apparent suicide attempt following complaints about interference in a case he was presiding over.