KAMPALA, Uganda—Huawei Technologies Co., the world’s largest telecommunications company, dominates African markets, where it has sold security tools that governments use for digital surveillance and censorship.

But Huawei employees have provided other services, not disclosed publicly. Technicians from the Chinese powerhouse have, in at least two cases, personally helped African governments spy on their political opponents, including intercepting their encrypted communications and social media, and using cell data to track...