No, unless countries have specifically signed up to accept refugees, or willingly allow refugees into their country, no country has an obligation to accept refugees.
Egypt has publicly refused to accept any mass Palestinian refugees, for decades. And in the recent conflict offered alternative solutions, and even suggested that if other countries care about the issue so much, they should take them:
Egyptian President Abdel Fattah El-Sisi has himself dismissed out of hand the possibility of taking in Palestinian refugees. The Egyptian leader said, "Why can't Israel transfer the refugees to the Negev desert until the armed groups in Gaza like Hamas and Islamic Jihad are dealt with."
... According to a report in the British newspaper "Financial Times" this week, an Egyptian official told a European official who proposed the idea: "You want us to take a million people? Then we are going to send them to Europe. If you care so much about human rights, well you take them."
Apart from the usual economic and security concerns of giving refuge to foreigners, Egypt strongly believes that this won't be a temporary thing. Once refugees enter their country - legally or illegally - international law obliges them to address their humanitarian needs and prevents them from forcing them back into the country they fled from.
The core principle of the Refugee Convention is non-refoulement, which asserts that refugees should not be returned to a country where they face serious threats to life or freedom. India is not a signatory to the convention ... However, the principle of non-refoulement, now considered a rule of customary international law, is binding on all states whether they have signed the convention or not.
India is a good case study to consider the complexities of accepting refugees under a benevolent government and a right-wing anti-immigrant one.
During the genocide of Bengalis in East Pakistan (now Bangladesh) in 1970s, 10's of millions of refugees poured into India. And India willingly gave them refuge. But as persecuted Bengali refugees kept pouring in they strained India's economy and created internal political tensions. India pleaded with the international community to provide support for the refugees and relieve India's burden. But they only offered meagre support, and did nothing to stem the flow of refugees. India then decided to militarily train the Bengali resistance network and assisted them to overthrow the Pakistani regime, stop the genocide and encourage the refugees to go back home. This resulted in the emergence of Bangladesh as an independent country.
Fast forward to the present now, and India under the right-wing Modi government has refused to accept and treat Rohingya refugees (fleeing the genocide of their community in Myanmar) as refugees. Despite international pressure to accept more Rohingya refugees, the current Indian government has refused to do so. Instead, the Modi government even prefers to treat new refugees as "illegal immigrants" and holds them in detention centres. Due to this it even refuses them exit visas to other countries willing to take them as refugees, and instead tries to force them back to Myanmar itself.
India is not allowing exit permissions for Rohingya refugees who have completed refugee status determinations with the UN Refugee Agency (UNHCR) and “gained approval from third countries for resettlement,” says a new report titled ‘A Shadow of Refuge: Rohingya Refugees in India’ ... On the one hand they are disallowed from leaving when they get a chance to resettle in another country, on the other, the Rohingya in India are vilified as “illegal migrants”, face growing “anti-Muslim and anti-refugee xenophobia”, and live under constant fear of being deported back to Myanmar, “to the genocidal regime from which they fled”.
Among the biggest challenges faced by Rohingya refugees in India, who number at least 20,000, is arbitrary detention. Once picked up, they are held in “holding centers” where conditions are “deplorable”, the study says. “Separating Rohingya children from their parents during detention remains another grave challenge,” says the report, which also includes a case study of such separation.
Members of Modi's party, the BJP, also publicly brag about attacking the refugees:
After a fire razed down a Rohingya camp in India’s national capital New Delhi in 2018, a BJP youth leader admitted to setting the shanties on fire on Twitter, saying, “Well done by our heroes… Yes, we burnt the houses of Rohingya terrorists.”
I cite the indian examples to highlight a major issue in accepting refugees - a country that accepts refugees has to also be prepared to accept that some of them will not go back.
Even after the creation of the Bangladesh nation-state, many Bengali refugees preferred to stay back in India and not go back (we are talking millions, by some estimate!). Benevolent politicians are accepting of such situation. But right-wing anti-immigrant ones obviously don't like this, and hence we see the current Modi government deliberately trying to create a hostile environment for the Rohingya refugees in India.
Israel has been trying to force Egypt to allow the Palestinians to "migrate" to Egypt for decades now. And Egypt has refused because it knows that Israel wants to occupy Palestinian territories and repopulate it with their own citizens. And so Egypt knows this is not going to be a temporary arrangement. It will have to deal with millions of refugees nowhere to go, and Egypt will be forever stuck with them. Under such circumstances, diplomatic pressure and emotional blackmail from Israel and the west is likely to fail, as no other sympathetic country will support them because of the precedent it sets - imagine if tomorrow the west asks your country to accept thousands or millions of refugees!?
Note also that Egypt has another important point in its favour - According to the UN, occupation of a territory, the forceful displacement of people from a territory, and repopulating it with another group of people is a genocidal act (note that Israel does not accept this definition).
Hence Egypt will be technically culpable in the genocide of Palestinians, along with Israel, if it accepts all the refugees from Gaza while Israel is chasing them away from their homes. Egypt's permanent acceptance of the Palestinians driven away by Israeli forces would imply a tacit approval to the Israeli occupation of the Gaza strip and its repopulation with Israelis. Without Egypt's cooperation, Israel cannot do this. Egypt's actions in not accepting the refugees is currently preventing a genocide (forceful killing and displacement of people).
Instead of trying to figure which country can be forced into accepting Palestinian refugees, the real, practical question is what can we politically do to prevent Israel (and the US) from turning Palestinians into refugees? War is not the only solution. (Especially when a disgraced authoritarian politician is Israel's Prime Minister, who may be just using this war to distract the Israeli public from his failures and to cling on to power).
References:
Egypt proposes Europe takes in Gaza refugees
Explainer: India cannot deport Rohingya refugees without violating international law.
Rohingya refugees in arbitrary detention, denied exit permissions by India: Report.
India Begins Deporting Rohingya Refugees.