$\begingroup$
$\newcommand{\V}[1]{\mathbf{#1}}$
The Pontryagin's maximum principle helps here to find out the general form of the control.
Let $\V S$ be the state vector contains the coordinates of the position vector $\V x$ and velocity vector $\V v$ side by side. So $\V S = (\V x, \V v)$.
The time derivative of $\V S$ is $\dot{\V S} = (\V v, \V a)$.
Overdot will denote the time derivative from now.
The running reward is a constant $r = -1$. As the longer the simulation runs the worse it gets.
The constraint is that $\V a \le A$, where $A$ is the magnitude of the acceleration. In your case it's 1, but can be any other constant.
We also have the costate vector $\V P$ of the same type as $\V S$.
Let $\V p_1$ and $\V p_2$ correspond to the first and second half of the vector so. $\V P = (\V p_1, \V p_2)$.
The control Hamiltonian is defined as follows:
$$
H(\V S, \V P, r) = \dot{\V S} \cdot \V P + r
$$
So in our case:
$$
H = \V p_1 \cdot \V v + \V p_2 \cdot \V a - 1
$$
For a time optimal control $H$ is maximal and is a constant (conserved).
This suggests that the direction of $\V a$ is the same direction as the direction of $\V p_2$ to maximize that dot product.
It also adheres to the equations of the Hamiltonian mechanics:
$$
\dot{\V P} = - \frac{\partial H}{\partial \V S} \\
\dot{\V S} = \frac{\partial H}{\partial \V P}
$$
The partial derivative with respect to a vector is a shorthand for the vector formed by the partial derivatives with respect to the elements of that vector.
The $H$ doesn't directly depend on the position only the velocity so
$$
\V{\dot P} = \left( \V 0, -\V p_1 \right)
$$
By integrating we have the costate:
$$
\V P = \left( \V c_1, \V c_2 - \V c_1 t \right)
$$
There $\V c_1$ and $\V c_2$ are constants of integration. So
$$
\V p_2 = \V c_2 - \V c_1 t
$$
And as we said before the acceleration points into the direction of this vector so your acceleration is in the form:
$$
\V a = A \frac{\V c_2 - \V c_1 t}{\left| \V c_2 - \V c_1 t \right|}
$$
So you can imagine a dot moving along a staright line with constant speed, and the direction of this dot tells you direction to accelerate.
In the literature this is often referred to as the "bilinear tangent law" because it's a tangent of an angle when expressed with angles instead of vectors.
Once you have this it's possible integrate this twice to get the general solution for speed and position and write up the non-linear system equations to solve for the constant vector of $\V c_1$ and $\V c_2$.
Solving the resulting non-linear system is difficult. It's discussed the paper: COMPUTING MINIMUM TIME PATHS WITH BOUNDEDACCELERATION
And references within.
$\endgroup$