I'm really just expanding on other people's comments, so I've made this answer community wiki.
If $R$ is a subring of a finite dimensional algebra over a field $K$ ($d$-dimensional, say), then $R$ embeds in $M_d(K)$ via the regular representation. So $M_n(R)$ embeds in $M_{nd}(K)$, and so $\text{GL}_n(R)$ embeds in $\text{GL}_{nd}(K)$.
This isn't a necessary and sufficient condition (as the much deeper results referred to in Mark Sapir's answer show), but is enough to deal with both examples in the question, since $\mathbb{Z}[D_8]$ is a subring of the finite-dimensional $\mathbb{Q}$-algebra $\mathbb{Q}[D_8]$, and $\mathbb{Z}_2[D_8,t^{\pm1}]$ is a subring of the finite dimensional $\mathbb{Z}_2(t)$-algebra $\mathbb{Z}_2(t)[D_8]$ (I think the OP uses $\mathbb{Z}_2$ to mean the integers mod $2$, but if it means the $2$-adic integers, then it's a subring of the finite dimensional $\mathbb{Q}_2(t)$-algebra $\mathbb{Q}_2(t)[D_8]$).
In particular, even Maschke's theorem isn't needed.