SHANGHAI — The Chinese electronics giant Huawei is preparing to sue the United States government for barring federal agencies from using the company’s products, according to two people familiar with the matter.

The lawsuit is to be filed in the Eastern District of Texas, where Huawei has its American headquarters, according to the people, who requested anonymity to discuss confidential plans. The company plans to announce the suit this week.

The move could be aimed at forcing the United States government to make its case against the Chinese equipment maker more publicly. It is part of a broad push by Huawei to defend itself against a campaign led by the United States to undermine the company, which Washington sees as a security threat. Executives have spoken out strongly against America’s actions, and new marketing campaigns have been aimed at mending the company’s image among consumers.

For many years, United States officials have said Beijing could use Huawei’s telecommunication equipment to spy and disrupt communication networks. The company has denied the allegations, but major wireless carriers such as AT&T and Verizon have effectively been prevented from using Huawei’s equipment as a result.