Man attempts suicide in court