Tech Mahindra has won a $500 million-plus, five-year deal from Telefónica O2—its biggest-ever contract in Europe—bolstering CEO Mohit Joshi’s turnaround push as telecom growth revives.