I wonder if the equation of motion of an oscillator with (position-dependent) damping \begin{equation*} \ddot{x}+\gamma(x)\dot{x}+\omega_{0}^{2}x=0 \tag{1} \end{equation*} can be derived directly from a stationary action principle?
Clearly, if $\gamma$ does not depend on the position, then the time-dependent damped Lagrangian $$\mathcal{L}(x,\dot{x},t)=e^{\gamma t}(\dot{x}^{2}-\omega_{0}^{2}x^{2})/2\tag{2}$$ would do the job.
Concerning a non-variational Lagrangian formulation, the above equation (1) can be derived by introducing the Rayleigh dissipation function $$Q(x,\dot{x})=-\frac{\partial\mathcal{F}}{\partial\dot{x}},\tag{3}$$ where $$\mathcal{F}(x,\dot{x})=\frac{1}{2}\gamma(x)\dot{x}^{2}.\tag{4}$$ However, does there exist a stationary action principle for equation (1)?