mIRC internally remembers which Server Group you connected to via the /server command or dialogs. But it's impossible to access this information via script.
Not to be confused with $server($server).group which is an entirely unrelated lookup and returns inaccurate results, especially if the server response from 001 numeric is not a server hostname that exists in your servers.ini. This can happen because you are connecting via ZNC/BNC or because you are connecting via Random Server round-robin, or because the 001 response contains a masked/fake server address.
Perhaps, instead, a $connection(N).servergroup / .servername / .serverip ($serverip already exists) / etc could be used to access these inaccessible connection state values.