Have the Neo-Guelfs win out, and have Pope Pius intervene initially in the war against Austria (as much as it will pain him to go to war against a Catholic state). This should not only win the Papacy enough resect that they will likely be seen as the natural head of a United Italy, but it shold also spare Pius the first of the traumatic experiences which soured him so badly on liberal nationalism in OTL. If you accomplish that, when the Italian Unification Wars really kick in, the Pope will likely seen the perfect head of an Italian state - they will have less of a territorial base than Sardinia-Peidmount, they will have a great deal of spiritual authority, and will be popular in all but the most radical communities in Italy.
Now, this won't be a theocracy in any but the loosest sense of the word (nor do I think it would work, if it was a totaltarian theocracy). The Pope would likely be established asthe Head of State, but there will naturally be a parliament where most of the power lies, and there will have to be some accomodations given to religious freedom - though the Church will certainly enjoy a special relationship akin to that of Ireland in the early and mid 20th centuries - freedom of the press, and the like. I suspect the Pope would take little role in the day to day managing of Italy and focus instead of the administration of the Church and theological matters (I don't care how much energy a man has, he can't do everything!)
However, it would be a fasinating scenerio to play out - both due to the impact it would have on Italy, as well as the massive changes it would have on 19th and 20th century Catholicism.