A federal judge in Brooklyn yesterday reserved ruling on whether Secretary of Labor Raymond J. Donovan should be ordered to testify at a coming trial of two former labor union officials accused of obstructing justice in an investigation of Donovan last year.

The trial of the two men, Louis Sanzo, former president of Laborers Local 29 in New York, and Amadio Petito, once the local's secretary-treasurer, is scheduled to begin next week before U.S. District Court Judge Mark A. Costantino.

Accused of lying to a federal grand jury about "no-show jobs" with Donovan's construction company on a subway project in Queens, Sanzo and Petito were indicted last March on charges of perjury, obstruction of justice and conspiring to impede the Donovan investigation. Petito's lawyer, Jeffrey Hoffman, subpoenaed Donovan as a defense witness last month. Sanzo's lawyer, Jeffrey Weisenfeld, joined in the move at a pretrial hearing yesterday in light of the government's plans to call a cellmate of Sanzo to testify for the prosecution.

Weisenfeld read some excerpts from a four-page "debriefing" statement as illustrative of what the unidentified jailhouse informer said Sanzo told him at the Metropolitan Correctional Center in Manhattan earlier this year. According to the statement, Sanzo purportedly said:

"This Donovan, this expletive deleted , he's got everything and we've got expletive deleted . He ain't helping nobody, he is just sitting on his expletive deleted throne, has done everything we did. When he had his construction company, he had no-shows like we did."

According to another excerpt read into the court record, the informer alleged that "Sanzo said he gave $20,000 to the Reagan campaign."

Seeking to quash the subpoena served on Donovan, the labor secretary's attorney, Dean Burch, said at the hearing that "Secretary Donovan knows nothing about this case . . . and . . . his testimony would be negative."

In a 2 1/2-page affidavit, Donovan declared that he has "no knowledge or information concerning whether there were so-called 'no-show' employes on the Vernon Boulevard job"--a $53-million project that launched Donovan's company, the Schiavone Construction Co. of Secaucus, N.J., into the New York subway-building business in 1975.

Donovan said he knew Sanzo, but not Petito, and said he had no knowledge of whether either defendant was "involved in any of the matters alleged in the indictment."

Both defense lawyers took the position that Donovan's denials on the witness stand would be helpful to their case. Judge Costantino said he would have to "wait until the government's case is presented to see if Secretary Donovan will have to appear." He also set a final pretrial hearing for next Wednesday on whether to admit the informer's testimony.