Yes, this generalizes to Hochschild cohomology and André-Quillen cohomology.
Given a category $\mathcal{C}$ with finite limits and an object $X$, you can form the category of Beck modules $\operatorname{Ab}(\mathcal{C} / X)$, abelian group objects in the slice category over $X$. When $\mathcal{C}$ is the category of groups, a Beck module over $G$ is precisely a split extension of $G$ with abelian kernel, so Beck modules can be identified with $\mathbb{Z}[G]$-modules.
In nice cases, the category $\operatorname{Ab}(\mathcal{C} / X)$ is abelian, and the forgetful functor $\operatorname{Ab}(\mathcal{C} / X) \to \mathcal{C} / X$ has a left adjoint, called abelianization $\operatorname{Ab}_X$. The Hochschild cohomology of a Beck module $M$ is defined to be $HH^i(X; M) = \operatorname{Ext}^i(\operatorname{Ab}_X X, M)$. In the groups case, $\operatorname{Ab}_G G$ is the augmentation ideal, so Hochschild cohomology is just group cohomology shifted by 1.
Hochschild cohomology itself is only an approximation to André-Quillen cohomology, which is somehow a more homotopically correct notion (I don't know enough about any of this to explain what this means, exactly). In the case of groups, these two cohomology theories coincide. I suggest having a look at Martin Frankland's thesis, which gives a good overview of these things. It works out explicit examples (groups, abelian groups, associative algebras, commutative algebras) very nicely in Appendix A.