I would love to know the context behind why you are trying to achieve this? What is the end goal?
Carrying this out would require advanced coding, and so requires hiring a Shopify expert to carry this out. Would removing the specific countries from the approved shipping zones be an option? Then customers from these countries will not be able to complete checkout, they will see an error stating that their region is not supported. This guide outlines how to do this. Another option which may work for is using a third party app that can block access from specific countries, here’s an example of an app that carries this out.
I would like to use this script because there is no way to only limit specific payment gateways to specific countries. This is a core feature that is missing.