Somalia handed Hassan Sheikh Mohamud the presidency for a second time following Sunday’s long-overdue election in the troubled Horn of Africa nation, which is confronting an Islamist insurgency and the threat of famine.