This is Summer from the Social Care team at Shopify. Thanks for your question!
At the moment, it's not possible to restrict a payment gateway to a location or a product. Customizing the checkout through coding sounds like a great idea to achieve this, however, if you're on the Basic, Shopify, or Advanced plan, it's not possible to edit the checkout. The reason for this is that the checkout code is not made accessible for its security; so we can ensure that your information and your customers' remain safe at all times.
The checkout can still be edited but this is only viable when you're on the Shopify Plus plan, which is our subscription plan made for large enterprises. If you are on this plan, I recommend reaching out to a Shopify Expert to see if they are able to customize the checkout to fit your requirements. They're the best point of contact to provide confirmation on coding customizations as they have the expertise to support coding.
Other than editing the checkout, the only other feasible option right now is to open separate stores and assign different payment gateways to each store.
I understand these workarounds may not be a potential solution so what I can do is share this feedback with our development team. It's not a guaranteed solution, however, it's good to pass this on so the team is aware of what features you would like to see in the platform and so they can possibly consider adding this feature in the future.
For me to precisely relay the importance of assigning a payment gateway to a location or product, do you mind providing more information as to how this feature would impact your business?