I have done this as follows:
Let $G$ be a non-abelian group of order $10$.
If possible let a non-identity element say $a \in G$ is in $Z(G)$.
Now by lagrange's theorem , $|a|= 2,5$ or $10$.
If $|a|=10$
$|a|$ can't be $10$ (because then,$ G=<a> $, which will be a abelian group).
If $|a|=2$
Now, every non-identity element of $G$ will be of order $2$ or $5$. Now , their must be some element of $G$ of order $5$ (because if every non-identity element of $G$ be of order $2$, then $G$ will be abelian) say $c \in G$ , and $|c| = 5$. since, $a \in Z(G)$, so it will commute with every element of $G$, hence $ac=ca$ . Also $|a|=2$, $|c|=5$ . So $|ac|=10$. Which is again not possible since $G$ is non-abelian. Therefore, $|a| \neq 2$.
If $|a|=5$
Then $a,a^2 ,a^3,a^4 \in G$ , & all of these have order $5$ . So, in $G$ number of non-identity element of order $5$ will be $4k$ , where $k \in \Bbb{N}$. So if $G$ contains only non-identity element of order $5$, then order of $G$ will be of form $4k+1$ . But $10$ can't be of form $4k+1$. So there must be a non-identity element of order $2$ say $d$. Again by similar argument as above $|ad| = 10$ , which is again an impossibility. So$|a| \neq 5$.
Therefore our assumption that $a$ is a non-identity element that is in $Z(G)$, is wrong. So$ Z(G)$ has only identity element. So it is a trivial subgroup of $G$.
If any mistakes please correct. And if you could provide a better solution than, please do.