As they try to diagnose the Williamsburg Bridge's many ills, officials are confronting a perplexing choice: spend $250 million to repair the heavily used crossing and replace its cables, a task that has never been tried while a bridge is still in service, or build an entirely new structure, which might be twice as expensive.

The Williamsburg's steel towers have decayed, its foundation is cracked, huge beams have deteriorated, the walkway and roadway are worn and there is rust throughout. But its biggest concerns - no one yet knows how big - are four cables, each a foot and a half thick, that support a crossing used on a typical day by 89,000 automobiles, 17,000 trucks, 84,000 subway riders, 4,000 bus passengers and 400 pedestrians.

The cables, each woven from 7,696 steel wires, have been corroding since they were strung above the East River nearly 84 years ago. Replacing them without closing the bridge would be akin to restringing a pearl necklace while it is around someone's neck.

Then again, some fear that building a new bridge in this era of environmental impact statements might invite legal challenges that could result in substantial delays.

With sophisticated sensors and other electronic gear arrayed together on a suspension bridge for the first time, state and city officials are monitoring the Williamsburg's creaks and sways. The results of the effort, which was begun about six weeks ago and may continue indefinitely, are to be presented to a panel of experts that is to make recommendations on the bridge's fate.

''What we're doing will be a model for all other bridge builders,'' said Mayor Koch, who is to name the panel today.

To ease the strain on the bridge, traffic has been restricted to six of the eight lanes. But the city's Transportation Commissioner, Ross Sandler, stressed that the Williamsburg is safe, at least for now.

In fact, an inspection of the heart of Cable D, the most problematic of the cables, indicates that the damage there, though irreversible, could be less extensive than once feared. But there is more serious damage at the anchorage on the Manhattan side, and a cable is only as strong as its weakest point.

''It is likely that the most significant event in public works will be the reopening of the Williamsburg Bridge after its renewal,'' said Mr. Sandler, leaving open the question of how it will be accomplished, ''both because of its importance and the challenge it presents.'' The Woes Of Cable D A tour of the bridge earlier this month began at the heart of the problem: the anchorage near the Franklin D. Roosevelt Drive, where Cable D separates into 37 groups of wires that loop around steel ''eye'' bars and merge back into the cable for a return trip to Brooklyn.

''Do we have five years or 25?'' asked the city Transportation Department's first deputy commissioner and chief engineer, Samuel I. Schwartz, examining stray wires flying away from the bundles like cowlicks. ''The secret lies in this anchorage.''

According to daily inspections, there are 165 breaks, a net loss of up to 330 wires, since each strand should cross the bridge twice. Countless other wires have been pitted by moisture, losing strength as they lose thickness.

No one is sure why Cable D deteriorated more than the other three, which have relatively few broken strands. With its northern exposure, Cable D may be affected more by the elements. Engineers have also detected a slight bend just before it enters the anchorage. Tiny Instruments Attached

To monitor Cable D's condition, experts from Steinman, Boynton, Gronquist & Birdsall, one of the project's engineering consultants, have attached tiny instruments called strain transducers to the eye bars to measure how much they stretch when a load on the bridge causes the cable to pull. (A subway train will extend one inch of an eye bar 10 to 30 millionths of an inch, they have found.) Should a bar begin to stretch less, it could mean that some of the wires attached to it are no longer pulling their share of the weight or may even have snapped.

They are also using a spectrum analyzer to listen to the pitch of the eye bars as they vibrate. The frequencies may reveal that all is not as it should be.

These instruments will be augmented by lasers that will measure to a fraction of an inch the cable's sag at various points. This fall, there will be a photographic survey of the bridge, loaded and unloaded, by helicopter. It will be compared with similar photographs shot in 1984. Working Wire by Wire

Meanwhile, inspectors using wooden wedges are gingerly working wire by wire into the core of Cable D at its low point in the middle of the bridge, an area believed to be particularly vulnerable because of the accumulation of water there. At various depths in the cable, they will snip off 32 short segments of wire for metallurgical tests, a procedure they will repeat at points on two other cables where wires were damaged in a fire during the bridge's construction.

Although they have discovered more pitting and corrosion in Cable D, officials are relieved not to have found many broken strands. ''You don't have to worry about a catastrophe,'' said Charles E. Carlson, deputy commissioner of the State Transportation Department, after climbing up on a scaffold beside the Manhattan-bound lanes to inspect the wires.