Let $\mathfrak{A}$ be an algebra (in the sense of universal algebra). To each term $t(x_1,...,x_n)$ in the language of $\mathfrak{A}$ in which each variable actually appears we can assign a group $G_\mathfrak{A}(t)\subseteq S_n$ consisting of all permutations of the variables which results in the same function: $$G_\mathfrak{A}(t)=\{\sigma\in S_n: \forall a_1,...,a_n\in\mathfrak{A}(t(a_1,...,a_n)=t(a_{\sigma(1)},...,a_{\sigma(n)})\}.$$
Now let $\mathbb{G}(\mathfrak{A})$ be the class of isomorphism types of groups of the form $G_\mathfrak{A}(t)$ for some term $t$. I'm curious which classes of groups can arise this way.
Is there a snappy description of the classes of isomorphism types of finite groups which are of the form $\mathbb{G}(\mathfrak{A})$ for some algebra $\mathfrak{A}$?
EDIT: for a more focused subquestion, is there an $\mathfrak{A}$ such that $\mathbb{G}(\mathfrak{A})$ consists exactly of the finite $2$-groups? Certainly it's possible to get only $2$-groups - see e.g. this MSE answer of Eric Wofsey.
Here are some example $\mathbb{G}(\mathfrak{A})$s (ignoring up-to-isomorphism details):
If $\mathfrak{A}=(A;\star)$ where $\star:A^2\rightarrow A$ is a bijection, then $\mathbb{G}(\mathfrak{A})$ consists only of the trivial group.
If $\mathfrak{A}=(\mathbb{N};\max)$, then $\mathbb{G}(\mathfrak{A})=\{S_n:n\in\mathbb{N}\}$.
Already something like the naturals with exponentiation seems tricky: we can make things complicated by "nesting symmetries" as in $$(x^{[(a^b)^c]})^{[(u^v)^w]}$$ or by equating variables in terms which already give rise to complicated symmetry groups. The fact that we really only have a single nontrivial equation to lean on doesn't seem to trivialize the situation.