Two finite-dimensional prime algebras (in a certain extended sense, what includes the usual algebras with binary multiplication over a field) with the same identities are isomorphic over the algebraic closure of the ground field (Yu.P. Razmyslov, Identities of Algebras and Their Representations, AMS, 1994, p. 30 onwards). This suggests that the proper condition one should impose on finite groups to guarantee that the same identities imply isomorphism, would be something related to primeness.
Unfortunately, Razmyslov's reasonings seem not be extendible to a broader class of algebraic systems, in particular, to groups: the linear structure is crucial there (a relatively free algebra in the corresponding variety is enlarged, via the action of a suitable extension of the ground field, to an algebra which is isomorphic to an extension of the initial algebra). Also, it is not clear what the group-theoretic analog of primeness should be in this context.
However, there is an old result saying that two finite simple groups with the same identities are isomorphic (H. Neumann, Varieties of Groups, p. 166, Corollary 53.35). I believe that the machinery developed in that book (critical groups, etc.) would allow to answer this question for any reasonably defined class of finite groups.