An important factor here is the treaties a country has signed up to. In this case, a relevant one is the 1951 Refugee Convention. From UNHCR:
The 1951 Refugee Convention is the key legal document that forms the basis of our work. Ratified by 145 State parties, it defines the term ‘refugee’ and outlines the rights of the displaced, as well as the legal obligations of States to protect them.
The core principle is non-refoulement, which asserts that a refugee should not be returned to a country where they face serious threats to their life or freedom. This is now considered a rule of customary international law.
Then there is the 1967 convention, which Wikipedia has the following about:
Where the 1951 United Nations Convention Relating to the Status of Refugees had restricted refugee status to those whose circumstances had come about "as a result of events occurring before 1 January 1951", as well as giving states party to the Convention the option of interpreting this as "events occurring in Europe" or "events occurring in Europe or elsewhere", the 1967 Protocol removed both the temporal and geographic restrictions. This was needed in the historical context of refugee flows resulting from decolonisation.
Many countries are party to those treaties, as illustrated by the image below:

Image from Wikipedia, in the public domain
The legend:
Light Green = party to only the 1951 Convention
Yellow = party to only the 1967 Protocol
Dark green = party to both
Regarding consequences
As for consequences of not taking refugees in practice, there don't seem to be many, if any at all.
UNHCR reviewed the treaties in 1989 and point 23 of that review illustrates the tone with which nations are addressed:
- The above is a general survey of the types of problems which impede the full and effective implementation of the 1951 Convention and its 1967 Protocol. They are presented with a view to opening constructive dialogue on how States and UNHCR, individually and jointly, might facilitate and improve implementation of the Convention and Protocol on a global basis.
Furthermore, in its conclusion, it restates the goal, which is providing protection to refugees, not to force individual signatory states to take refugees:
The ultimate goal of this exercise is to strengthen the collective capacity of States to meet the protection needs of all refugees.