Can you find $y$ minimizing $|\int_a^b y|$? Let's consider, for $a < b, \alpha, \beta \in \mathbb{R}$ and $y \in \mathcal{A} := \left\{ y(x) \in C^2([a, b], \mathbb{R}); y(a) = \alpha, y(b) = \beta) \right\}$.
We want to find all the functions $\left(\tilde y_n\right)_{n \in \mathbb{N}}$ such as their definite integral between $x = a$ and $x = b$ are extremal (equation below for minimal):
$$\tilde y = \underset{y\in \mathcal{A}}{\min} \left| \int_a^b y(x) \ dx \right|$$
This integral can be seen as the surface under the $y$ curve if $y(x) > 0 \ \forall x \in [a, b]$, or the sum of positive and negative surface contrubutions otherwise if $y(x)$ admits one or several roots in $x \in [a, b]$.
For example, let's consider $(a, b) = (-1, 1)$ and $(\alpha, \beta) = (0, 0)$. The functions $y \in \mathcal{A}$ should look like:

Their can be two kind of extrema: minima and maxima.

*

*Maxima are easily ruled out. Indeed, the surface under the curve can tend to $+\infty$.  For instance, $\int_a^b -A (x^2 - 1)  \ dx \rightarrow + \infty$ for $x \rightarrow + \infty$, so their is no maximum for $y \in \mathcal{A}$.

*The only possible minimum is $0$. So, basically, any function such as $f(x) = -f(-x)$ and $f \in \mathcal{A}$ should be solution of this problem, e. g. $\tilde y = \sin(\pi x)$. Their would be an infinite number of solutions, thus.

That said, my resolution was based on a specific example, and I would like to find a general solution for all admissible $a, b, \alpha$ and $\beta$, e.g. by using the variational principle.

Update: After the bounty started, @kevinkayaks then @Qmechanic provided an idea very likely to solve the problem, defining $G[y] = I[y]^2$. It is already a good progress, but it would be $100$% satisfying if the resolution was with the functional I defined there. If it is proven that the resolution with $G[y]$ is totally equivalent to the resolution with $I[y]$, ok for me. If not, I would appreciate to see the correct resolution with $I[y]$ (maybe by correcting some mistakes in my original attempt of answer?). Thank you!
 A: One problem is that OP's functional $$I[y]~=~ |F[y]| ,\qquad F[y]~:=~ \int_a^b \!dx~y(x) ,$$ is not differentiable. If we instead consider the related squared functional
$$ G[y]~:=~ I[y]^2~=~F[y]^2, $$
it is at least differentiable
$$ \frac{\delta F[y]}{\delta y(x)}~=~1\qquad\Rightarrow\qquad \frac{\delta G[y]}{\delta y(x)}~=~2F[y]. $$
Then stationary configurations $x\mapsto y(x)$ are characterized by $F[y]=0$, which has infinitely many solutions, and which are clearly minima for the functional $G$.
A: Without using variational principles, you could prove that $$\inf_{y\in\mathcal{A}}\left\vert\int_a^by\,dx\right\vert=0$$
Take $y(x)=0$ in $[a+\frac1n,b-\frac1n]$ and then glue it to $\alpha$ and $\beta$ using polynomials in such a way that the function stays bounded by a constant $M$ independent of $n$. I can write down the explicit computations if you want.
Then
$$0\le \left\vert\int_a^by\,dx\right\vert\le \int_{b-\frac1n}^b|y|\,dx+\int_a^{a+\frac1n}|y|\,dx\le 2\frac{M}n\to 0$$
as $n\to\infty$. This shows that the infimum is zero. It follows that the only solutions are the ones with integral zero.
Edit
If you take $a=0$ then in $[0,\frac1n]$ the polynomial you want is
\begin{align*}
y(x)  & =\alpha-\alpha n^{3}x^{3}+3\alpha n^{2}x^{2}-3\alpha nx,\\
y^{\prime}(x)  & =-3n\alpha\left(  nx-1\right)  ^{2},\\
y^{\prime\prime}(x)  & =-6n^{2}\alpha\left(  nx-1\right).
\end{align*}
When $0\leq x\leq\frac{1}{n}$, you have
$$
|y(x)|\leq\alpha+\alpha+3\alpha+3\alpha=8\alpha
$$
Also $y(0)=\alpha$, $y(\frac{1}{n})=y^{\prime}(\frac{1}{n})=y^{\prime\prime
}(\frac{1}{n})=0$.
