Yes, this is e.g considered in Ref. 1. In field theory, the starting point is the off-shell action$^1$
$$\tag{1} I[\phi; t_f,t_i]
~:=~\int_{t_i}^{t_f} \! dt~\int_{\Sigma} d^3x~
{\cal L}(\phi(x,t),\dot{\phi}(x,t), \partial_x \phi(x,t);x,t) , $$
where $t_i$ and $t_f$ denote initial and final times, respectively.
We now impose appropriate boundary conditions (B.C.), e.g. Dirichlet B.C.
$$\tag{2} \phi^{\alpha}(x,t_i)~=~\phi^{\alpha}_i(x)
\qquad \text{and}\qquad \phi^{\alpha}(x,t_f)~=~\phi^{\alpha}_f(x) . $$
We assume that for given B.C. (2) there exists a unique solution $\phi_{\rm cl}$ to the Euler-Lagrange equations. OP is interested in the (Dirichlet) on-shell action defined as
$$\tag{3} S[\phi_f,t_f; \phi_i,t_i] ~:=~ I[\phi_{\rm cl}; t_f,t_i].$$
Next define (Lagrangian) momentum field
$$\tag{4} \pi_{\alpha}(x,t)
~:=~\frac{\partial {\cal L}(\phi(x,t),\dot{\phi}(x,t), \partial_x \phi(x,t);x,t)}{\partial \dot{\phi}^{\alpha}(x,t)}, $$
and energy
$$\tag{5} h(t)~:=~\int_{\Sigma} d^3x~\left(\sum_{\alpha}\pi_{\alpha}(x,t)\dot{\phi}^{\alpha}(x,t)
-{\cal L}(\phi(x,t),\dot{\phi}(x,t), \partial_x \phi(x,t);x,t)\right).$$
Then one may show field-theoretically$^{2}$ that
$$\tag{6} \frac{\delta S}{\delta \phi^{\alpha}_f(x)}~=~ \pi_{\alpha}(x,t_f), \qquad \frac{\delta S}{\delta \phi^{\alpha}_i(x)}~=~ -\pi_{\alpha}(x,t_i) ,$$
and
$$\tag{7} \frac{\partial S}{\partial t_f}~=~-h(t_f), \qquad \frac{\partial S}{\partial t_i}~=~h(t_i). $$
Example: A free field Lagrangian density ${\cal L} = \frac{1}{2}\phi^2$ leads to
$$ \tag{8} S(\phi_f,t_f; \phi_i,t_i) ~=~ \frac{1}{2(t_f-t_i)} \int_{\Sigma} d^3x~(\phi_f(x)-\phi_i(x))^2 .$$
References:
MTW; Section 21.1 and Section 21.2.
L.D. Landau & E.M. Lifshitz, Mechanics, vol. 1, 1976; $\S$ 43.
--
$^1$ For actions in point mechanics, see e.g. this Phys.SE post.
$^2$ For a proof in point mechanics, see e.g. Ref. 2 and my Phys.SE answer here.