It is written in standard textbooks on classical mechanics that, advantage of Lagrangian equations is that nowhere do enter statement regarding (Newtonian) force.
e.g. To find Lagrangian $L = T - U$, for simple pendulum, we have
$$T=(1/2)ml^2\dot{\theta}^2 $$ and $$U=mgl(1-\cos\theta).$$
But definitely, we must know the force acting on the bob of simple pendulum to find the potential energy $U$. That force is $F_g = mg$, where symbols have their usual meanings. The potential energy is derived from force, as $U = -\int_{y=0}^{y=h} \vec{F}. \vec{ds} $. And we get $U = mgh$.
Then we make argument that there is one degree of freedom, and we need one generalized co-ordinate, namely, $\theta$, and then we will replace $h$ by $\theta$.
If we replace gravitational force acting on the bob of pendulum by some other force which is a function of space co-ordinates only (& not time), obviously, we will get different potential energy function.
So without knowledge of force, how can we find Lagrangian $L$?