Malaysian opposition leader Anwar Ibrahim has lost his final appeal against his conviction for a sex offence.