Manchester City will have to pay ex-player Benjamin Mendy around £8.5m after a judge ruled the club had wrongly stopped his pay.