Hello cenko2-3486,
I assume your connection to the SQL server resource is handled within your script. If yes, replace with a connection reference to the Data gateway cluster.
Here's an example of adding a data gateway via PowerShell. You may need to refactor based on your script's language.
Once your script is updated, re-import into your runbook and re-test. Also recommend checking out this reference on using runbook authentication to a local resource.
Hope this helps.