A Prince George's County judge has ordered County Executive Lawrence J. Hogan to sign a labor contract with public employes that has been the subject of a complex 15-month dispute in the state courts.

The ruling by Circuit Court Judge Robert Mason marks the third time that a county judge has ordered Hogan to sign the agreement with the American Federation of State, County and Municipal Employees.

The tug-of-war over the signing of the contract with the county's 1,500-member public employes union has been going on ever since a tentative agreement was negotiated in February 1980. The case has gone all the way to the state's highest court and back down again through the county courts.

Yesterday, County Attorney Robert Ostrom said he is still not certain that Hogan will sign the contract. Instead, the county may appeal this latest ruling, which came in a late-night hearing. Tuesday.

But whatever happens, the contract in dispute is one that covers the period between July 1, 1979, and this June 30, and it is due to expire on that date.

Ostrom said yesterday that even if Hogan does place his signature on the contract, the county will fight its implementation, arguing that the union breached the agreement when it went on strike last August.

Kenneth Niman, a lawyer for the union, disagrees. The contract was never signed and never went into effect, Nyman said yesterday, and therefore, nothing was breached when the union struck last August.

Union members, including clerical and maintenance workers, road repair crews and jail guards, went on strike for 11 days last August during the dispute, but returned to work and voted to pursue the matter in court.

The long-running labor dispute began in February 1980 when negotiators for the union signed a tentative agreement considered favorable to the county.

However, when the contract was presented to Hogan for his final approval, he angrily refused to sign it, according to sources familiar with the incident. What angered Hogan was not the contract, but statements political adversaries on the County Council who criticized this handling of the negotiations.

The union took the case before a hearing examiner, who ruled that Hogan had violated county labor laws by vetoing the tentative agreement because of political considerations, and the examiner ordered him to sign it. A county judge and later the state's highest court upheld that finding.

Then on May 1, a three-judge panel ruled that Hogan was not required to sign the contract, stating that the union had chosen an inappropriate legal route for relief. The union returned to court, and Mason ruled Tuesday that Hogan must sign.