Take $x(0)=x_0$ and $x(T)=x_T$. Minimize $$I=\int_0^TL(x,\dot{x})\,dt\;\;\text{with}\;\;L=(\dot{x}+x)^2$$ by solving the Euler-Lagrange equation, $$\frac{\partial L}{d x}=\frac{d}{dt}\frac{\partial L}{\partial \dot{x}}.$$ The solution is $$x(t)=a e^t+be^{-t},\;\;a=\frac{e^T x_T-x_0}{e^{2 T}-1},\;\;b= \frac{e^{2T} x_0-e^T x_T}{e^{2 T}-1}.$$ The resulting integral is $$I=(\coth T-1) \left(x_0-e^T x_T\right)^2.$$ We still need to minimize this by varying $x_0$ and $x_T$ in the interval $[m,M]$, at fixed $T$. I assume $M>0$.
We need to consider several cases:
• If $m\leq 0$, we can just take $x_0=0=x_T$ and reach the minimal $I_{\rm min}=0$.
• If $m>0$ and $T\leq\ln(M/m)$ we can take $x_0=me^T$, $x_T=m$ to reach the minimal $I_{\rm min}=0$.
• If $m>0$ and $T>\ln(M/m)$ the minimum is reached at the end points of the interval, $x_0=M$, $x_T=m$, with $I_{\rm min}=(\coth T-1) \left(me^T -M\right)^2$. In the limit $T\rightarrow\infty$ this tends to $I_{\rm min}\rightarrow 2m^2$.
Here is a plot of $I_{\rm min}$ as a function of $T$ for $m=1$, $M=4$.