Mary Sue Hubbard, wife of the founder of the Church of Scientology, was sentenced in federal court here yesterday to four years in prison for her role in a conspiracy to plant church spies in government agencies, steal government documents and bug at least one government meeting.

Hubbard, whose husband, L. Ron Hubbard, founded the controversial organization about 30 years ago, sobbed as she told U.S. District Judge Norma Holloway Johnson that she "sincerely and publicly apologized" for her actions.

Johnson ordered Hubbard, who has been free pending appeal of her 1979 conviction in the case, to turn herself in to federal officials in three weeks to begin serving her sentence.

Hubbard's lawyer, Michael Madigan, urged that the 51-year-old Hubbard be sent to a halfway house facility rather than prison because she is ill and would not receive adequate treatment in prison. Johnson, while sentencing her to a minimum security prison, did so under a law that would permit Hubbard to be released at any time if the prison could not treat her ailments properly.

In papers filed with the court, Hubbard maintained that she and the church had been victims of government harassment. Assistant U.S. Attorney Raymond Banoun told Johnson that the "government absolutely and unquestionably rejects these allegations."

Johnson said that she did not know whether the government had harassed the church, but "even if I assume . . . there was harassment, I still cannot accept what you did" as excusable.

Hubbard, who lives in Los Angeles, is the last of 11 church leaders who were indicted in the conspiracy in August 1978 to go to prison. The indictments came after the FBI raided church headquarters here and in Los Angeles in 1977. The raids were said to be the largest ever conducted by the FBI.

Documents introduced in court by prosecutors in 1979 contended that operatives of the church initiated numerous break-ins at government offices here, including the Justice Department, and that they secretly placed a listening device in an Internal Revenue Service conference room--all in an apparent effort to combat what the church called government harassment.

Although church officials in 1979 condemned the 4-to-6-year sentences imposed by U.S. District Judge Charles R. Richey on several of the church leaders as too harsh, Madigan told Johnson before sentencing that Hubbard "believes she has been treated very fairly" by the judge. Church leaders in Washington could not be reached for comment.

Madigan said that Hubbard had resigned from the church in 1981, and would not engage in any activities connected with the church in the future.

The organization is engaged in an internal struggle over control of assets. Ronald E. De Wolf, son of the 71-year-old founder, has asked a court in California to have a trustee appointed for his father's estate on the grounds that his father, who has not been seen since March 1980, is either dead or possibly held captive by some members of the church.

De Wolf has contended in court that the present church leadership is misusing the estate, according to his attorney, Michael J. Flynn. A hearing has been set for April 18 in California to determine whether a trustee should be appointed because L. Ron Hubbard is a missing person.