Some of the U.S.’s biggest pharmaceutical companies sued the Trump administration to try and block a rule that would force them to put the price of their drugs in television advertisements.

In the lawsuit filed in federal court June 14, Merck & Co., Eli Lilly & Co., Amgen Inc. and an advertising trade association claim that the Department of Health and Human Services doesn’t have the legal power to compel drugmakers to include prices in their ads, and that doing so would also mislead patients.

Many drugmakers, including Lilly and Amgen, have created websites to disclose prices, but argued that...