SHENZHEN, China—Huawei Technologies Co. filed a lawsuit challenging a law signed by President Trump in August that restricts federal agencies from doing business with the Chinese company, the latest in a series of countermoves by the telecommunications giant.

The lawsuit challenges the constitutionality of parts of the National Defense Authorization Act, an annual measure that authorized billions of dollars in military spending and put new limits on federal dollars going to Huawei and its Chinese rival, ZTE Corp. The law...