The most interesting part of the Euler-Lagrange equation is $\sum_i (L_p)_{x_i}$, which is the divergence of
something. Of course you know how this leads to $\Delta u$: it's the divergence of $Du$.
What field should we take so that its divergence involves $D\varphi\cdot Du$? There are two choices:
$u\,D\varphi$ and $\varphi\, Du$. Let's try them:
$$\operatorname{div}(u\,D\varphi) = D\varphi\cdot Du + u\,\Delta\varphi$$
$$\operatorname{div}(\varphi\,Du) = D\varphi\cdot Du + \varphi\,\Delta u$$
I think the second option looks more attractive, since $\Delta u$ should appear in the equation,
and $u$ by itself should not. Problem is, we have undifferentiated $\varphi$ in front of the Laplacian,
and we shouldn't.
This is where the exponential trick comes in. It's used all the time in ODE to get rid of undifferentiated functions.
For example, to solve $u'=3u$ we can write $u=e^w$ because then the equation become$e^w\,w'=3e^w$.
Here $e^w$, formerly known as $u$, cancels out, leaving a very simple equation $w'=3$.
Let's try the same idea here: instead of $\varphi$ write $e^{\varphi}$.
$$\operatorname{div}(e^\varphi\,Du) = e^\varphi D\varphi\cdot Du + e^\varphi\,\Delta u
= e^{\varphi}(D\varphi\cdot Du + \,\Delta u) $$
Good, but we need a minus sign there. So,
$$\operatorname{div}(e^{-\varphi}\,Du) = -e^{-\varphi} D\varphi\cdot Du + e^{-\varphi}\,\Delta u
= e^{-\varphi}(-D\varphi\cdot Du + \,\Delta u) $$
It remains to create $e^{-\varphi}f$ in the equation, which I leave for you to do.
OK, here it is: $L(p,z,x)=e^{-\varphi(x)}\left(\frac12|p|^2-f(x)z\right)$. Check that it works.