Proof of principle of stationary action when the Lagrangian is not $L=T-V$ The principle of stationary action claims that the action $S$ takes a stationary value in a real  system, where:
$$S = \int_{t_1}^{t_2} L dt\tag{1}$$
and $L$ is the Lagrangian of the system. It can be proven that $S$ is stationary when $L$ satisfies the Euler-Lagrange equation:
$$\frac{d}{dt}(\frac{\partial L}{\partial \dot{q}})-\frac{\partial L}{\partial {q}}=0.\tag{2}$$
If $L=T-V$ this equation is proven using d'Alembert's principle, from which we derive the following:
$$\frac{d}{dt}(\frac{\partial T}{\partial \dot{q}})-\frac{\partial (T-V)}{\partial {q}}=0,\tag{3}$$
which equals the Euler-Lagrange equation for a Lagrangian $L=T(q, \dot{q})-V(q)$
(where $\frac{\partial V}{\partial \dot{q}}=0$).
However, the Lagrangian is not always $L=T(q, \dot{q})-V(q)$. For example, if the potential depends on the generalised velocity of the particle (i.e. $V = V(q,\dot q)$) then the equation (3) derived from d'Alembert's principle, is no longer equivalent to the Euler-Lagrange equation, and no longer proves the principle of stationary action. So how can we prove that the principle of stationary action holds in systems where $L\neq T(q, \dot{q})-V(q)$?
And a side question: Doesn't d'Alembert's principle (and the equation (3)) hold in systems where $L\neq T(q, \dot{q})-V(q)$? If it does, why cannot this be used as our equation of motion?
 A: *

*In many systems (in particular outside the topic of classical mechanics) the principle of stationary action is taken as a first principle/axiom, i.e. it has no proof per se. The choice of action is often guided by certain sought-for features and symmetries.


*However OP is apparently only considering the class of systems in Newtonian mechanics$^1$ that obey d'Alembert's principle, cf. e.g. this & this Phys.SE posts.


*Then one may derive Lagrange (L) equations,
$$\frac{d}{dt}\frac{\partial T}{\partial \dot{q}^j}-\frac{\partial T}{\partial q^j}~=~Q_j+\ldots, \qquad j~\in \{1,\ldots, n\},\tag{L} $$
cf. e.g. this Phys.SE post. (The ellipsis $\ldots$ stands for possible semi-holonomic terms.)


*If and only if

*

*all constraints are holonomic, and


*all generalized forces $Q_j$ have a (possibly generalized velocity-dependent) potential $U(q,\dot{q},t)$ such that
$$Q_j ~=~ - \frac{\partial U}{\partial q^j} + \frac{d}{dt} \frac{\partial U}{\partial \dot{q}^j},\qquad j~\in \{1,\ldots, n\},\tag{*}$$
then the Lagrangian becomes of the form
$$L~=~T-U.$$
Only then the Lagrange (L) equations become Euler-Lagrange (EL) equations,
$$\frac{d}{dt}\frac{\partial L}{\partial \dot{q}^j}-\frac{\partial L}{\partial q^j}~=~0, \qquad j~\in \{1,\ldots, n\},\tag{EL} $$
i.e. the principle of stationary action becomes valid. $\Box$


*Notice that in the above reasoning, the generalized forces $Q_j$ were introduced prior to the potential $U(q,\dot{q},t)$. Also note that definition (*) is crucial.


*See also this related Phys.SE post.
--
$^1$ We mention for completeness that there is a well-known relativistic generalization of the kinetic term $T$.
A: I will first give some general remarks about Hamilton's stationary action, and then I will write specifically about the case you are asking about: a force that is a function of velocity.

The criterium of stationary action expresses the following demand: as an object is moving along some trajectory the rate of change of kinetic energy must match the rate of change of potential energy continuously. (As opposed so any kind of averaging.)
Here is how that 'continuously' comes into play:
Let's say you have obtained a trajectory from coordinates $(q_1, t_1)$ to $(q_3, t_3)$.
You can subdivide that trajectory in multiple subsections, for simplicity I will divide in two concatenated subsections: from $(q_1, t_1)$ to $(q_2, t_2)$ and from $(q_2, t_2)$ to $(q_3, t_3)$
If the action is stationary for the trajectory from $(q_1, t_1)$ to $(q_3, t_3)$, then if you evaluate the sections $(q_1, t_1)$ to $(q_2, t_2)$ and $(q_2, t_2)$ to $(q_3, t_3)$ individually: for each the action will be stationary.
In order for the action to be stationary from $(q_1, t_1)$ to $(q_3, t_3)$ the action must be stationary for each of the subsections. The subdivision reasoning goes down all the way to the limit of infinitisimally short subsections, concatenated. (This property was first pointed out by Jacob Bernoulli, older brother of Johann Bernoulli, in the course of solving the brachistochrone problem.)
So we have that the criterium of stationary action expresses the demand that as an object moves: from instant to instant, down to infinitisimal, the rate of change of kinetic energy must match the rate of change of potential energy.


To express motion taking place in terms of conversion of energy a necessary requirement is that the potential energy is well defined.
A necessary condition for the potential energy to be well defined is that as an object moves from a spatial coordinate $q_1$ to a spatial coordinate $q_2$ the difference in potential energy must be independent of how the object moves from position $q_1$ to position $q_2$. Mathamatically: any path integral from $q_1$ to $q_2$ should arrive at the same value for the net amount of work done.
As mentioned in the answer by Qmechanic: a necessary condition for that is that the constraints are holonomic.
A force that is a function of velocity
Another condition relates to what you are asking about: what if there is also a force present that is a function of velocity?
As we know, an example of a force-that-is-a-function-of-velocity is friction. If you don't have a way of accounting for the energy conversion due to friction then there is no direct way to use energy description to obtain an equation of motion.
Incidentally:
There is a force such that while it introduces a velocity dependent contribution it is still possible to arrive at a well defined potential energy. That force is the Lorentz force.
The effect of the Lorentz force occurs at right angles to the velocity vector. As we know: the Lorentz force vector turns with the velocity vector, always acting perpendicular. As we know: a force that acts perpendicular to the velocity vector does not change the magnitude of the velocity, hence it does not change the kinetic energy.
Returning to Hamilton's stationary action:
In the general case:
If there is a force contribution that is a function of velocity (and not at right angles to the velocity vector), then there is no well defined potential energy, and then the physics taking place is for Hamilton's stationary action out of scope.
That is: Hamilton's stationary action has a domain of applicability and if the potential energy is not well defined then the physics taking place is not in the domain of applicability of Hamilton's stationary action.


Interderivabilty
As pointed out by physics.SE contributor knzhou: in physics you can often run derivations in both directions
There is a way to proceed from $F=ma$ to Hamilton's stationary action.
It's a two stage process; the intermediate stage is the work-energy theorem.
A corollary of the work-energy theorem is that as an object is moving along some trajectory the rate of change of kinetic energy will match the rate of change of potential energy.
That is: in order to go from F=ma to Hamilton's stationary action the work-energy theorem is sufficient; using d'Alembert's principle is not a necessity.
