How to get second derivative of state as a output of state-space model?
An ideal acceleration sensor can be modeled using the original equation itself.
$$
a = Cx+ Du =
\begin{pmatrix}
0 &amp; 0
\end{pmatrix}
\begin{pmatrix}
x\\
\dot{x}
\end{pmatrix}
+
\begin{pmatrix}
1/m &amp; -1
\end{pmatrix}
\begin{pmatrix}
F\\g
\end{pmatrix}
$$
Attach the above C and D matrices as the second row of the corresponding matrices in your original output equation. The original output equation represented an ideal position sensor. Now the augmented output equation represents a position sensor (Ist row) and an acceleration sensor (IInd row).
$$
y_1 = \begin{pmatrix}
y\\
a\end{pmatrix}
= 
\begin{pmatrix}
1 &amp; 0\\
0 &amp; 0
\end{pmatrix}
\begin{pmatrix}
x\\
\dot{x}
\end{pmatrix}
+
\begin{pmatrix}
0 &amp; 0\\
1/m &amp; -1
\end{pmatrix}
\begin{pmatrix}
F\\g
\end{pmatrix}
$$
The above is for an ideal sensor. If you want to estimate the acceleration, you may need an estimator which uses the measured states and the inputs and outputs an estimate. If you want to model a non ideal sensor, you will need the above equations as well as additional states and  inputs to model the bandwidth, bias, noise etc. of the non ideal sensor.