The Senate, trying to fashion a Pentagon bill President Reagan would sign, bogged down Friday in a fight over whether to permit Japan to buy the Navy's sophisticated Aegis air defense system to help patrol the western pacific Ocean.

The bill would ban sales of the Aegis to Japan unless that nation also buys American-built ships. Japan wants to buy the Aegis system alone for installation in Japanese-built ships.An amendment to eliminate the ban was offered by Sen. Bill Bradley, D-N.J. The Aegis system is constructed in New Jersey.

Japan wants to buy four of the Aegis sytems at a cost of $526 million each.

Bradley argued that "for years, Congess has urged Japan to do more. In buying Aegis, Japan would be doing just that." Requiring Japan to take American hulls for Aegis will kill the deal because Japan has not bought a foreign-built ship for more than 100 years, Bradley said.

But Sen. Ted Stevens, R-Alaska, said, "providing the technology to Japan alone would weaken our competitive position with them and with other nations in shipbuilding."

Reagan vetoed an earlier Pentagon budget bill because he objected to its reductions in his request for "Star Wars" anti-missile spending and Democratic-added arms control policy restrictions he opposes.

When he vetoed the bill Wednesday, Reagan indicated he might be able to accept the appropriations measure, which contains the same cuts in spending for the Strategic Defense Initiative, as Star Wars is formally known, but none of the arms control limitations.

However, those restrictions could be added as the Senate tries to finish work on the bill befores its adjourns next week for a summer recess that won't end until after Labor Day.

The Senate also may add to the bill a proposal to send new humanitarian aid to Nicaragua's Contra rebels, but to restrict sharply the possibility of future military help. Reagan is seeking a package that includes immediate military aid.

Reagan vetoed the bill which authorized the Pentagon budget. That measure is the first half of the two-step congressional budget process which also includes an appropriations bill that has money to pay for programs in the earlier authorization measure.

Although the vetoed measure authorized $299.5 billion worth of Pentagon spending and the appropriations bill proposes $282 billion, the legislation is essentially the same. Dollar totals in authorization bills generally are higher because they cover more projects in future years.

When the Senate finishes work on the appropriations bill, it will go to a House-Senate conference committee to be reconciled with separate legislation enacted by the House six weeks ago.

Senate Democratic leaders are considering adding the vetoed bill as an amendment to the appropriation measure, which could force another showdown with Reagan.

Democrats have decided not to attempt to override the veto, because they couldn't muster the two-thirds vote needed in each chamber.

Reagan had sought $4.8 billion for "Star Wars" next year, compared with the program's current budget of $3.9 billion. The vetoed bill would have cut his request to $4 billion and added other restrictions on what type of anti-missile systems could be developed.

The appropriations bill contains $3.7 billion for Star Wars, and a separate appropriation measure for the Energy Department included another $300 million for related research. That would bring the total for next year to the $4 billion level rejected by Reagan.