Defense Secretary Caspar W. Weinberger signed an agreement yesterday enabling Japanese firms to participate in the Strategic Defense Initiative (SDI) program, after gaining new security safeguards because of a Japanese transfer of sensitive submarine technology to the Soviet Union.

The agreement suggested that the Reagan administration was willing to set aside its anger over the Toshiba Corp.'s recent transfer of machinery for milling submarine propellers, even as a subcommittee of the House Armed Services Committee voted unanimously to take punitive action against the company.

The agreement, cosigned by Japanese ambassador Nobuo Matsunaga, demands that classified information on the SDI program, popularly known as "Star Wars," is handled in accordance with U.S. law and the international regulations governing high-technology exports to the Soviet Union that Toshiba apparently disregarded.

"We feel we have ample arrangements to protect the technologies that we would work on together," Weinberger told Reuters yesterday. "There will be no loss of technology, I'm convinced."

A senior Pentagon official briefing reporters on the grounds that he not be identified said the security provisions in the agreement are "comparable" to those already governing SDI participation by private firms in Britain, Germany, Italy and Israel.

But the official added that it was nonetheless a big step for the Japanese to accept the provisions and that the Toshiba case had "facilitated" their acquiescence "to a {security} regime which we have long felt was necessary and which we now have in place."

The agreement followed more than two years of delicate negotiations that were said to be motivated in large part by the desire of a half-dozen major Japanese firms to gain access to potential technological spinoffs from SDI research.

U.S. and Japanese officials said that under the agreement, parts of which remain secret, the Pentagon has unlimited rights to classify or retain any products of Japanese SDI research, but that it will also respect Japanese rights to pertinent information generated without direct U.S. support.

Actual Japanese involvement may be fairly limited, if a more general 1983 agreement for the transfer of Japanese military technology provides any guide. It was not until 1985 that implementing regulations were developed and so far only two such transfers have occurred.

The impending agreement aroused some criticism in Japan, which explains its involvement in the controversial program on the grounds that SDI's ultimate goal is the elimination of nuclear weapons. The country is officially opposed to all nuclear weapons.

The House subcommittee vote, meanwhile, was to cut off sales of Toshiba products at Defense Department posts around the world, sales worth $23 million last year. The Senate has already voted to bar imports of Toshiba products for up to 5 years, and similar legislation is pending in the House.Tokyo correspondent John Burgess contributed to this report.