Rodrigo Duterte kept a "death squad" of gangsters as mayor of a southern Philippine city, the ex-president told an inquiry into drug killings during his reign.