The former doctor even wrote the judge at his BFF's sentencing.