So, g must be symmetric in local coordinates.
In order for g to be locally the Jacobian of a vector field X=(X1,X2,…,Xn), we must have that there are functions fi(x1,x2,…,ˆxi,…xn) for all i with gi,j=∂∂j(∫gi,i dxi+fi)=∂∂i(∫gj,j dxi+fj) for all i≠j. X will then be (∫g1,1 dx1+f1,…,∫gn,n dxn+fn)
Then, to answer your question, X must itself be a gradient field; this will happen locally if and only if the 1-form ω=X♭ (musical isomorphism) has its exterior derivative η=dω equal to 0 (this functions as a "curl" of the vector field).