Officials throughout Maryland said yesterday a radical shake-up in the public schools may result from a court ruling that declared the present school financing system unconstitutional because if favors children in wealthy localities.

But despite expressions of fear and alarm in Montgomery County and jubilation in poorer school districts, officials acknowledged that it would take years before local school systems feel the effects of Tuesday's ruling, even if it is upheld by higher courts.

The ruling by Baltimore Supreme Bench Judge David Ross said that the state constitution requires each school district in Maryland to spend essentially the same amount of money per pupil, regardless of the capacity of taxpayers there to finance their schools. He ruled that it is ultimately up to the state to eliminate the differences.

Under the present system, taxpayers in counties like wealthy Montgomery pump millions of dollars into public schools, while poorer counties and the city of Baltimore have no such resources. The judge ruled that a wealthy county's ability to raise hefty tax revenues does not justify the great disparity between educational opportunities for Maryland children in rich and poor communities.

For Montgomery County. "This is the worst possible decision in my view, because it obliterates local choice," said State Del. Lucille Maurer (D-Montogmery), one of the architects of the present school-funding formula, which puts no limit on how much a local school district can spend for each pupil.

Officials said Montgomery would have to cut more than $13 million from its school budget if the legislature fixed spending at the present state average.

Attorney Elliott Lichtman, who represented the four low-income school districts that filed the suit, countered that, "Local control isn't very meaningful if you don't have local resources. This may enhance local control, because it means districts like Baltimore City, Somerset County, Caroline County and St. Mary's County will have greater opportunities."

But Lichtman urged caution in speculating on the effects of the ruling, which has not even reached the appeals court. "There are lots of alternatives that would not cause any injury to students in Montgomery County," he said.

Maryland officials have already announced plans to appeal the ruling, and attorneys said that it could take more than a year for the state's highest court to rule on the case. Even then, it could take several years before the legislature implements a system to equalize spending.

"There's no way that starting Sept. 1, 1982, we could require every [locality] to spend what Montgomery County spends. That is not a feasible suggestion," said House Speaker Benjamin L. Cardin (D-Baltimore). "You cannot accomplish pure, equal allocation of resources in a short amount of time."

Cardin said the legislature will not take any action until the appeal is complete.

To satisfy the judge's ruling, the legislature would have to scrap the present school financing system. Under that system, Montgomery County spent $2,328 per pupil in 1978 -- the year at issue in the court case -- while rural Caroline County spent $1,498. In its place, the legislature would have to enact a system in which the same amount of money is spent for every pupil in the state, unless there are legitimate educational reasons for variations -- such as salaries needed to attract qualified teachers or concentrations of students with special needs.

It would be up to the legislature to set the amount of money spent for each child in the public schools in Maryland's 23 counties and the city of Baltimore.

State officials noted that it would cost Maryland $700 million to equalize funding. "Add that to $200 million we expect to lose in federal funds from 'Reaganomics,' and we're almost a billion dollars worse off than we were two weeks ago," said a spokesman for Gov. Harry Hughes.

And the widely varying, emotional reactions to the ruling foretell a rancorous legislative battle over how to refashion school financing if the judge's ruling is upheld.

Similar rulings have struck down school financing formulas in several other states during the last decade. In Washington State, after a 1977 ruling, the state established a fixed, minimum amount that must be spent in each school district. The state pays that amount, but allows local districts to add up to 10 percent extra.

In New Jersey, a 1973 ruling was not implemented until three years later, when a judge closed down schools for several days because of legislative inaction. Within days, the legislature passed a new state income tax to finance the changes, but much of the money raised is going to tax relief rather than to education.