A court handed the ex-president a life sentence concluding the country’s biggest political crisis in decades after his brief imposition of emergency rule.