My first answer on this site, here goes...
I used to dabble in microbiology, and at first I dismissed your question as simply impossible. However it kept me thinking, and I came up with a chain of events.
- Viruses 101
We have to remember that viruses are tiny and very very simple. They each have their tiny bit of genetic code, a capsule of some type and a few enzymes. They don't have a metabolism of their own, they are just a vessel for a few genes basically relying on cheer number and luck to spread. It is debated if they even are "alive". They rely entirely on their hosts to execute their only function: reproduction. This task usually overwhelms their host cells, who die performing it. Each virus strain has at most a few viable host cells.
- Evolution 101
For any new ability for our virus to develop we need random mutations that make it better at competing against other organisms taking the same living space. A mutation occurs in a single virus, and is passed on to its offspring. Some viruses can pass segments of their genome to other viruses when they come to direct contact with them. Reproduction is the only "goal" of lower lifeforms, before our virus develops a conscience, it is simply implausible for it to survive with a trait that is a burden. Humans can make choices that hinder their ability to reproduce, but viruses whose ability to reproduce is hindered are snuffed out by more virulent ones.
- Viral mass
For a hive mass of viruses to develop, the viruses would need special hosts that can sustain them for a long period of time. The viral genes that turn their hosts into virus factories would need to have some sequence to slow the process down, as to not take over the whole of the cells metabolic capacity and burst them, as is the usual MO of viruses. Slowing down reproduction is not a strong card in natural selection, but if keeping host cells alive would guarantee them building new viruses for a longer period of time, the virus strain could in theory survive. Now we have a special host capable of sustaining our virus (=doing everything for it) on its way to greatness.
As previous answers have pointed out, communication between neurons is the base of our human consciousness. For your viruses to develop intelligence, they need a rudimentary means of communication between units. Depending on the sustaining host, I think it can take different forms. For example, different cells of the immune system communicate with chemical signals secreted or on their surface, plant cells are directly connected to each other and of course neurons use a combination of electricity caused by ion shifts and chemicals. Search for other examples from nature to find one that suits your need.
For communication to develop to our strain we of course need these random mutations to give it an edge over competitors. Maybe the capability to communicate helps the host cell evade danger? Again examples from nature can be drawn.
- Hive mass
We have viruses that have enduring hosts that can communicate. Now they need a reason to aggregate and form large masses. The human brain has up to 100 trillion synapses. This goes beyond my expertise, but biologically I don't see a reason why a mass of units of a similar number of connections couldn't theoretically form a single conscience.
Now I imagine this sapient hive as a mass of undifferentiated cells, containing only billions upon billions of units of the chosen host cell including our viral genome. The size needed depends on the means of communication, even more connections than in the human brain might be needed. You also might need to take into account the being's size vs communication speed between units, which can result in much slower thinking compared to humans (this can bring new sides to your story). The being cannot reproduce itself as a whole, but is immortal. Physically the mass cannot reside inside another being, since the lifespan would be too short. It should be somewhere where it can constantly find new hosts to aggregate to the existing mass to replace dying host cells or to grow. A body of water comes to my mind.
- Is it still a virus?
The being reproduces its units by spreading vessels containing genetic code that take over host cells aka by spreading viruses. The genes used to communicate between units and aggregate to the existing mass would have to be contained in these viruses. The host cells do all the metabolic work but without the viral genome, they wouldn't be a part of this hive-being. The viral genome must be quite big at this point, but in nature viruses have huge variation, and biggest viruses found have a genome of two megabases, coding over 2000 different proteins.
To simplify, by conscience here I mean awareness of self and the capability of forming goals other than simple reproduction. This again goes beyond my field of expertise. Since in us humans our awareness of self is largely shaped by the environment we perceive with our senses, it is hard to imagine what the conscience of a big lump of undifferentiated cells would be like. However, it has an endless lifespan as long as its existence and its environment stay balanced. We are in the realm of speculation now.
- Ability stealing
This is the most complicated part. The viruses the hive sends out to gather new hosts could gain mutations that make them able to take different cells as hosts. Then the virus in a new cell can take in its genome bits of the hosts genes and according to its base coding compel the host to aggregate with the hive. There it will spread it's newly gained genes with the rest of the hive. The problems with this:
- the outgoing viruses don't have a will or plan, the potential hosts they find is based on luck
- the new genes taken in are random
- the units returning to the hive have most probably gathered useless crap genetic code
- when gathered is spread to the rest of the hive units it is like accumulation of useless trash which will sorta weigh the units down or be downright detrimental by integrating into needed genes
- number of useful genes gathered / amount of thrash = tiny
This all leads to the conclusion that the hive would need to somehow filter the genetic material brought by the returning units. This goes against the basic function of viruses: singular viruses gather genetic material at random and natural selection eliminates the ones that got something detrimental or even too much useless weight. Our hive however cannot die everytime a piece of garbage sequence is brought back.
- Viruses in host brain
I haven't been able to think of a way this would work. Even if a strain of virus could integrate itself in all of a brains neurons without killing the host animal and somehow form a new conscience there, it would die when the host animal dies. It wouldn't be able to make plans or at least see them through. Maybe a new animal contracts the strain and a new conscience develops in its brain, but it wouldn't have the memories of the previous one or even knowledge of its existence.
To recap. A lasting central mass is needed, it has to be composed of supporting host cells each containing the viral genome to control it to communicate and aggregate. The hive "secretes" tons of viruses that bring back viable hosts and new genetic material. The genetic material has to be somehow filtered and tested. This being needs a huge amount of time and luck to develop when we remember the driving forces of evolution: random mutations and natural selection.
Interesting problem! I hope my explanation didn't complicate things too much.