An Italian police officer has told a court in Rome he watched colleagues beat a 31-year-old man who later died in custody.