I'll appreciate it if you help me to tackle this situation.
I'm going to characterize 2-group $G$ whose two main properties such as $cd(G)=\{1,2\}$ and there is normal abelian subgroup $P$ such that $G/P \cong Q_8$.
I'll appreciate it if you help me to tackle this situation.
I'm going to characterize 2-group $G$ whose two main properties such as $cd(G)=\{1,2\}$ and there is normal abelian subgroup $P$ such that $G/P \cong Q_8$.
Copyright © 2021 JogjaFile Inc.
This answer refers to a previous version of the question.
I think you are asking for examples of this situation: $G$ is a finite 2-group and $P \leq Z(G)$ is a central subgroup with $G/P \cong Q_8$ quaternion of order 8.
Example 1: $G=Q_8 \times A$ for $A$ any abelian 2-group. Here we choose $P=1\times A$ so that $G/P \cong Q_8$. As claimed, $G/Z(G) \cong Z_2 \times Z_2$ and $\operatorname{cd}(G)=\{1,2\}$.
Example 2: $G = \langle i,j,x,y : i^2 =x, j^2 = y, ji=ijx; x,y \text{ central of order 2}\rangle$. We choose $P=\langle xy \rangle$ so that in the quotient $xP = yP = z$ in the usual presentation of $Q_8$. As claimed, $G/Z(G) = \langle iP, jP \rangle \cong Z_2 \times Z_2$ and $\operatorname{cd}(G)=\{1,2\}$.
Non-existence theorem: If you were thinking there were no examples, you might be remembering something close: If $G$ is a finite 2-group and $1 \neq P \leq Z(G) \cap [G,G]$, then $G/P \not\cong Q_8$ can never be quaternion of order 8. However, if $P$ is allowed to be outside of $[G,G]$ then you get many possibilities.
Vocabulary: Instead of asking "Can $Q_8$ be a central extension of a $2$-group $G$", I think you mean "Can a $2$-group $G$ be a central extension of $Q_8$. The "extension" is the bigger (extended) group.
If you really did mean the way you asked, then yes $Q_8$ is the extension of $Z_2 \times Z_2 \cong Q_8/Z(Q_8)$ by the central subgroup $Z_2 \cong Z(Q_8)$. But the $G,H$ in your question have nothing to do with that.