A senior Treasury official warned the Japanese government yesterday that its credibility is declining in the world because of repeated failures to follow through on promises to open its trade and capital markets.

Assistant Secretary David C. Mulford, in the strongest public criticism of Japan so far from the Treasury, said in a speech to the Japan Society in New York that the result had been "a rise in 'Japan-bashing' behavior even by sympathetic observers, who have concluded that perhaps continued threats and pressure are the only way to get needed results."

Mulford's theme that "Japan bashing" may be necessary to encourage a turnaround in the U.S. trade deficit is also the major argument behind the restrictive trade legislation that is pending in Congress. The administration opposes that legislation.

Mulford's tone was one more of sorrow than anger. He argued that while more needs to be accomplished, there had been substantial underlying progress made in the past four to five years in U.S.-Japan economic relations.

"Much of what I say will be in a positive vein," he said. "But I want to alert you to an underlying note of frustration at the partial, fragmentary nature of much of the progress.

"It seems that, time and again, the final achievement falls short of the initial promise. Examples abound -- economic stimulus packages (at least until the most recent announcement) which on closer examination contain little of substance; changes in capital markets that seem to move deregulation further into the future; lack of genuine follow-through on the Maekawa report; on restructuring the Japanese economy; 'trade liberalization' that does not lead to increased trade flows."

The Reagan administration has applauded the Japanese government's latest economic stimulus package, which includes a tax cut and increased spending on public services.

The Maekawa Report, prepared by a blue-ribbon Japanese committee and endorsed by the administration of Prime Minister Yasuhiro Nakasone, pledged Japan to concentrate on domestic rather than export-led expansion, with collateral commitments to boost consumer living standards and to reduce Japan's huge current account surpluses. Mulford said he is convinced that the progress made in U.S.-Japanese relations over the past four or five years is greater than generally believed. "This is not, of course, the prevailing view and I am willing to acknowledge, as I have already said, that there are ample grounds for the skepticism that presently abounds among Americans," he said.

He asserted that in the broad areas of economic policy coordination between Japan and the United States, more had been accomplished than recognized in press accounts.

He predicted that there would be important results stemming from that process, including long-term reform of the Japanese tax system and an expansionary budget policy.

But Mulford took pains to deny that the United States is as dependent on Japanese capital flows to finance its budget deficit as some people have reported. He said net Japanese purchases last year of U.S. public debt securities were only $18 billion, or less than 7 percent of total sales. As of March 1987, Mulford said, Japanese investors held only 3 percent of U.S. public debt securities.

In citing the most positive elements of the U.S.-Japan economic relationship, Mulford stressed three broad areas of what he called "the yen/dollar process" -- internationalization of the yen; access of foreign institutions to the Japanese market; and liberalization of the domestic Japanese financial market.

But even here, Mulford had some complaints. He acknowledged "startling results" in the internationalization of the yen, through development of a Euroyen market. Starting from $1 billion in Euroyen bond issues in 1984, the total swelled to $18 billion in 1986, and to $17 billion in the first six months this year.

Although the bulk of Euroyen issues is later swapped by the issuer into other currencies, Mulford stressed that "international investment behavior is being transformed, and Japan's currency is gradually establishing a broader role."

But on access to the Japanese market, Mulford said Japan had responded in "penny ante" fashion to foreign interest in participation in the primary market for Japanese government bonds. He was referring to a recent decision to boost from 0.9 percent to only 2.2 percent the share of such bond issues that could be underwritten by foreign firms.

"When no such restriction exists in our government bond market, this kind of penny ante response to a major issue of access and fairness is the kind of action which is undermining Japan's credibility," Mulford said.