Can we run SQL queries from Dynatrace Managed cluster or security gateway to a DB server?

Either write an extension or use another tool to do the query and send the result to Dynatrace using one of the APIs.