Yes and no.
Ants will always attempt to work together and have no competing factions within them* but their minds are NOT connected. In fact their seemingly intelligent behaviour is created through the interactions between individual ants which all follow the same simple rules over and over and over again.
Most ant behavior is actually caused by simple triggers (a chemical that causes a certain behaviour like increased agressiveness or makes the ant follow a trail of that chemical, vibrations on the ground that cause a flight or fight reactions, a touch on their mouthparts causes the ant to regurgitate food) - ants usually aren't very intelligent (except for some ants like ponerine ants which are actually pretty smart for insect standards) but their interactions have evolved to be very efficient in design.
The individual ant is like a body cell of a greater organism (that's where the term "superorganism" comes from) and all those "cells" are working together by simple rules which in the end produces a very smart result.
However anyone who knows these rules can easily cheat the ants - there is an abundance of creatures that parasite on ants - mites that sit on the ants and can touch other ants with their feelers so the ants feed those mites (the mites don't harm the ants but effectively steal from their food), beetles that live within army ant swarms and get ignored by the ants because they smell like an army ant (those beetles either eat ant brood or ant garbage), workerless ant species that live inside colonies of other ant species (they don't just get fed, the host colony will also raise their alate brood) and much much more (there's over 150 parasitic species known that live within Eciton army ant colonies alone, which is probably the record - most ants don't have many parasites because the nuptial flight (which army ants don't have) is a bottleneck that prevents many parasites from spreading to the descendant colonies of their current host colony).
In Stellaris the Hivemind is probably the government form that comes closest to the "superorganism" structure of ants (mechanically machine empires would do as well).
*That's actually not entirely right - there are studies about olygogynous Myrmica species (olygogynous = they have a smaller number of multiple queens, something between 2 and around 10, which live in different locations within the same colony) showing that sometimes there may be a bit of trouble.
The workers of these olygynous colonies are permanently busy mixing the odors of their different queens within the colony so every worker smells pretty much the same (this thesis is supported by the fact that workers can often be observed traveling between different nest entrances of the colony without actually transporting food or brood - apparently they do this for the sole purpose of promoting their queen's odor within another nest part).
The problems arise during nuptial flights - the new-born alates don't have the "mixed" colony smell but smell mostly like the queen that gave birth to them. So when a worker from another part of the colony comes by while the alates are emerging from the nest and said worker bumps into one of the alates it immediately recognizes that the alate smells different - it doesn't smell totally unfamiliar but not exactly right either. As a result such "guest workers" will often start grabbing and pulling around the alates (maybe even to "give them a pheromone bath until they smell right" like they are programmed to do with other workers) which never results in the alates getting injured but can of course delay their take-off.
p.s. Precursor world (forgotten species) is a very powerful trait for both Hivemind (because of their massive pop growth bonus that compensates for starting with only one pop, you should adopt synchronicity traditions first for an additional stacking pop growth bonus) and Machine Empire (if you take anything that increases leader cap - like the transcendent learning ascension perk or the factory overclocking civ perk - your leaders will reach those extremely high levels rather quickly due to the +200% leader exp gain and since they are essentially more-or-less immortal you have a very long time to make use of those high levels and the high research and government (resource production) bonuses that come with them).
The time your governors spend on those extremely high levels before they die/malfunction also easily compensates for the +15% consumer good costs.
I've always understood the seemingly intelligent decision making of eusocial animals as an emergent property of relatively simple rules which are followed by all members. There's no actual shared intelligence and they communicate by thoroughly conventional means - touch, smells etc - nothing spooky or telepathic going on.