You can use the alternate connection mechanism using the Cluster object, see https://tinkerpop.apache.org/docs/current/reference/#connecting-via-drivers
To pass configuration parameters a ClusterBuilder is available, see https://tinkerpop.apache.org/javadocs/3.7.3/core/org/apache/tinkerpop/gremlin/driver/Cluster.Builder.html
Also the gremlin-drivers for other software languages provide an option to pass configuration parameters in code instead of using a yaml file, see https://tinkerpop.apache.org/docs/current/reference/#gremlin-drivers-variants