WASHINGTON (AP) _ The Justice Department sued General Dynamics Corp. on Wednesday, alleging that the company improperly charged the government an undetermined amount on a $41 million contract to build a prototype of the ill-fated Sgt. York anti- aircraft gun system.

The civil suit, filed in U.S. District Court in Los Angeles, grew out of a government investigation that led to the indictment in December of General Dynamics and four current or former executives in connection with the Sgt. York, also known as the Division Air Defense Gun.

The indictment, to which the defendants have pleaded innocent, alleged a conspiracy to hide $7.5 million in losses on the Army contract to build prototypes of the gun by mischarging the losses to other government contracts.

According to the latest civil suit, General Dynamics improperly charged costs of fulfilling the $41 million fixed-price agreement to certain overhead accounts from 1978 to 1980.

General Dynamics said through a spokesman that the company expects the civil case, as well as the indictment, to be ''resolved in our favor.''

The civil complaint says the company improperly charged costs of fulfilling the fixed-price DIVAD prototype contract to independent research and development, bid and proposal, and general and administrative overhead accounts.

The government pays a contractor a proportion of the costs charged to these accounts in addition to what it pays under specific contracts. The result, says the suit, was that the company obtained overpayments to which it was not entitled.

The civil suit does not state the total amount believed to be involved, but the government's indictment in December said the charges resulted in a $3.2 million net loss to the government. A notice filed by the government with its civil suit said it would seek civil damages ''well into seven figures.''

The suit seeks damages under the False Claims Act and under common law theories of fraud, breach of contract, unjust enrichment and payment by mistake, said Assistant Attorney General Richard K. Willard.

''This civil case relates to the indictment which is pending before a federal court in Los Angeles,'' General Dynamics spokesman Alvin Spivak said in a statement. ''General Dynamics has pleaded innocent to the charges set forth in that indictment as have the individuals who also were named.''

''While we have not yet seen the complaint filed by the government,'' said Spivak, ''we anticipate that the civil case as well as the other pending case will be resolved in our favor when all the facts have been presented.''

The Justice Department plans to file a motion, probably this week, to put the civil case on hold, pending the outcome of the criminal case, said department spokeswoman Amy Brown. Such action is routine when criminal matters are pending.

The contract to build the DIVAD system, mounted on a tank and designed to protect tanks and infantry against low-flying enemy aircraft and helicopters, ultimately was won by Ford Aerospace and Communications Corp., a subsidiary of Ford Motor Co. The program was canceled last August by Defense Secretary Caspar W. Weinberger, who said the gun performed poorly in tests.

The General Dynamics prototype of the anti-aircraft gun was built at General Dynamics' Pomona, Calif., division.

The gun was intended to be a relatively simple weapon, but by the time the system was canceled seven months ago, the Army had spent more than $1.8 billion on it. Weinberger said last August that the gun's range of roughly 2.5 miles was not long enough and was about the same as existing weapons.

Those accused by the federal grand jury in Los Angeles in December included former General Dynamics executive James M. Beggs, who at the time of his indictment was administrator of the National Aeronautics and Space Administration. He has since resigned.

General Dynamics is one of the nation's biggest defense contractors, building Navy submarines, F-16 jet fighters for the Air Force, M-1 tanks for the Army and missiles and other systems.