Given a linear vector field $\mathrm v : \mathbb R^n \to \mathbb R^n$ defined by $\rm v (x) := A x$ and a point $\mathrm x_0 \in \mathbb R^n$, we would like to find a function $f : \mathbb R^n \to \mathbb R$ such that vector field $\rm v$ is orthogonal to the following level set
$$\mathcal S := \left\{ \mathrm x \in \mathbb R^n \mid f (\mathrm x) = 0 \right\}$$
and $\mathrm x_0 \in \mathcal S$. Let us demand that $\rm v$ be orthogonal to all level sets of $f$. Hence,
$$\nabla f (\mathrm x) = \mathrm A \mathrm x$$
Assuming that matrix $\rm A$ is symmetric and integrating the set of linear PDEs above, we obtain
$$f (\mathrm x) = \frac 12 \mathrm x^\top \mathrm A \, \mathrm x + f_0$$
Since $\mathrm x_0 \in \mathcal S$, the value of the integration constant is
$$f_0 = - \frac 12 \mathrm x_0^\top \mathrm A \, \mathrm x_0$$
and, thus,
$$f (\mathrm x) = \frac 12 \mathrm x^\top \mathrm A \, \mathrm x - \frac 12 \mathrm x_0^\top \mathrm A \, \mathrm x_0$$
If matrix $\rm A$ is not symmetric, then I do not know how to integrate the linear PDEs.
Example
Let $n=2$. Given $\mathrm A = \begin{bmatrix} 2 & 1\\ 1 & 2\end{bmatrix}$ and $\mathrm x_0 = \begin{bmatrix} 2\\ 0\end{bmatrix}$, we obtain the function
$$f (x_1, x_2) = x_1^2 + x_1 x_2 + x_2^2 - 4$$
The following plot depicts the level set (an ellipse) and the vector field. The length of the arrows is not proportional to $\| \rm A x \|_2$. The purpose is to show that the vector field is orthogonal to the ellipse.

Addendum
Let $n = 2$. The constraint $\nabla f (\mathrm x) = \mathrm A \mathrm x$ produces the following linear PDEs
$$\partial_1 f = a_{11} \, x_1 + a_{12} \, x_2 \tag{1}$$
$$\partial_2 f = a_{21} \, x_1 + a_{22} \, x_2 \tag{2}$$
Integrating equation (1) with respect to $x_1$, we obtain
$$f (x_1,x_2) = \frac 12 \, a_{11} \, x_1^2 + a_{12} \, x_1 \, x_2 + g (x_2)$$
Differentiating $f$ with respect to $x_2$ and using equation (2), we obtain the ODE
$$g' (x_2) = a_{22} \, x_2 + \underbrace{(a_{21} - a_{12})}_{= 0} \, x_1 = a_{22} \, x_2$$
which allows us to conclude that $a_{21} = a_{12}$, i.e., matrix $\rm A$ is symmetric. Integrating the ODE,
$$g (x_2) = \frac 12 \, a_{22} \, x_2^2 + c$$
where $c$ is an integration constant. Thus,
$$f (x_1,x_2) = \frac 12 \, a_{11} \, x_1^2 + a_{12} \, x_1 \, x_2 + \frac 12 \, a_{22} \, x_2^2 + c$$