Jordan's King Hussein said today that he is willing to sign a peace treaty with Israel if it withdraws from the territories it occupied in the 1967 war and recognizes the rights of the Palestinian people.

He indicated that such a treaty would have to be in the context of an overall peace settlement rather than as a separate peace.

This is not a basically new position for Jordan but coming after Egyptian President Anwar Sadat's visit to Israel and the bitter denunciation of it by Arab hard-liners, Hussein's statement had the effect of making clear that his basic sympathies lie with Sadat.

While Hussein did not absolutely rule out Jordanian attendance at the Egyptian-Israeli talks opening in Cairo on Wednesday, he left little doubt that such a move would be highly unlikely because Jordan is attempting to remain on good terms with Syria, a declared enemy of the Sadat initiative.

Hussein's statements came at a press conference talks with U.S. Secretary of State Cyrus Vance, who arrived here after meeting with Sadat in Cairo and Israeli Prime Minister Menahem Begin in Jerusalem.

American reporters accompanying Vance were given the impression yesterday that the United States expected Jordan to join the Cairo talks at a relatively early date. Hussein stressed today, however, that Sadat is acting for all the Arabs in feeling out the Israelis and that the Egyptian leader has not pressed Jordan to join what the king described as a "preparatory" meeting to pave the way for a general peace conference later in Geneva.

Hussein gave a cautious endorsement to Vance's high optimism. After talking to his American visitor, the king said that "possibly I feel a little more optimistic than I have felt for along time."

Hussein was careful to balance his high praise for Sadat with warm words for Syria's President Hafez Assad, calling him "a man of courage and wisdom."

Asked whether he felt closer to Egypt or Syria, Hussein replied, "I'd rather leave my thoughts in that regard to myself."

Although Hussein said Sadat has "taken a very courageous step on behalf of all of us," the Jordian leader seemed to be more reserved than Sadat has been about Israel's response. Hussein said there is still much skepticism and hostility in the Arab would because Israel has yet to show its readiness to respond in kind. It has given no clear and obvious signs." Husein said, of willingness to withdraw from occupied lands and to recognize the Palestinian people's right to self-determination.

Vance was quoted by his spokesman as being satisfied with Hussein's current attitude. The king described himself as serving as a bridge between Egypt and the Syria and as waiting to see how the Israelis reply to Sadat.

In effect endorsing Sadat's attempts to deal with the Israelis, Hussein said: "I believe that this is an opportunity that will never occur again . . . it is a final gesture made with sincerity and the greatest proof that we could offer the world of our good will.

"If we were to fail I can't begin to think of the disasters that could befall this area and maybe the world. This is a moment not to be lost and I hope that our friends in the United States wil do all they can to insure that this opportunity is not lost."

Asked if he agreed with Sadat's statement that the Palestine Liberation Organization has forfeited its right to be regarded as the sole representative of the Palestinian people, Hussein hedged but made clear his basic hostility to the PLO-Hussein nevertheless said response to a question that he could envision sharing a common border with a "PLO state."

"In this world I suppose anything is possible," was the answer of the man who has been the organization's leading Arab enemy ever since his forces crushed PLO attempts to take over his kingdom in 1970.