For example, if a hoplite at the front of a phalanx had his shield transfixed by a Roman pilum (and therefore couldn't use it), what would that now unprotected soldier do?
This is a tough question to answer. Ancient authors tend to write about battle on a more general level - talking primarily about who won and why. No surviving Classical source talks in any detail about actual combat. There are only allusions to the conditions of battle for the individual warrior. When our questions become too specific, we all too quickly run into a wall: there is no evidence.
Some scholars and amateur enthusiasts are working to fill in the gaps in our knowledge of ancient combat through what's known as "experimental archaeology" - recreating the equipment and the conditions of combat as closely as is safely possible, and then seeing what works best and what feels natural. The size and shape of the equipment itself suggests certain methods, and repeated tests can provide some hard data about reach, penetrative power and the like. This sort of experimentation feeds debates about how hoplites used their spears, whether they used their shields for literal pushing, and so on. However, while it might help us understand how Greek weapony was used, it obviously can't help us figure out how it wasn't. When you throw away the only connection to historical reality in your experiment - the shield, which has a known size and shape - you immediately enter the realm of pure speculation.
Now, we do hear about combatants losing their shields - but this never happens in combat. Hoplites would throw away their shields in order to run faster and flee more effectively. The loss of a shield was taken as a sign of cowardice; it suggested that the warrior's desire to save his own skin (by running) was stronger than his commitment to his city-state's cause (which he served by holding on to his shield and fighting). This is expressed most strongly in the famous phrase supposedly uttered by a Spartan mother to her son who was about to leave for war: e tan e epi tas, "with it or on it". The son was either to return with the shield, having fought and won, or to return on top of the shield, having died a noble death; under no circumstances was he to return without the shield, having saved himself but lost his honour. In Classical Athens, ten aspida apoballein or ten aspida rhiptein ("throwing/flinging away one's shield") was a punishable offence, and cowards would be mocked with the term "shield-flinger". However, in practice, in the heat of battle, few warriors probably cared that much about the legal repercussions if throwing away their shield meant that they could save their own life. On this topic, the Archaic poet Archilochos wrote these cynical lines:
One of the Saians now delights in the shield I discarded
unwillingly near a bush, for it was perfectly good,
But at least I got myself safely out. Why should I care for that shield?
Let it go. Some other time I'll find another one just as good.
Even if we never hear of any examples, perhaps we can take these lines to reflect the attitude of a warrior deprived of his shield in combat, too. Without his shield, he would be much more vulnerable. Indeed, strictly speaking, a hoplite without a shield was no longer a hoplite, since he was no longer "equipped" (the aspis shield being the decisive element in ta hopla, "the gear", that made a man a hoplite). Who could ask a non-hoplite to fight in the phalanx? Only the excessively brave or death-seeking would stay in the fight without the protection of a shield. Most men would likely regard it as a great excuse to leg it. Admittedly this is only my assumption, but let's face it - would any of us dare to stand up to hoplites with nothing but a spear (if it hadn't snapped yet) or a short little 2-foot sword?
So much for hoplites. Interestingly, there is an example of a Classical source describing combat in which one side's heavy infantry lost its shields. This was the decisive battle of the Greeks against the Persians at Plataia, in 479 BC. The Persian Immortals carried large wicker shields, but in battle they set these down to form a solid shield wall, which they used as cover while they rained arrows on their enemies. When the Greek hoplites charged, there was a fierce struggle over the wall of shields, but eventually the Greeks tore it down. This left the Immortals entirely without shields, and with only their body armour and their spears and swords to protect them against the enemy onslaught. Yet, Herodotos reports with respect and admiration, they fought on:
First they fought by the wall of shields, and when that was down, there was a fierce and long fight around the temple of Demeter itself, until they came to the pushing. For the barbarians took hold of the spears and broke them. Now the Persians were neither less valorous nor weaker, but they had no equipment...
-- Hdt. 9.62.2-3
The last phrase here is usually translated "they had no armour", but Herodotos' actual word is anoploi, "unequipped" - literally "lacking hopla". Since he points out elsewhere that the Immortals wore iron fish-scale cuirasses, Amelie Kuhrt has suggested (rightly, to my mind) that his statement must refer to their lack shields. Incredibly, they held on and fought bitterly against the hoplites; only a long and bloody battle of attrition finally broke their morale.
/u/Iphikrates has covered Greek warfare as well as anybody could. I would like to add however that there is at least one example in Roman accounts of warriors getting their shields transfixed by javelins, making them useless, so that the unfortunate warrior threw away his shield and fought without it (Caes. BG 1.25). In this case the warriors were of the German Helvetii. Here is the relevant excerpt:
The legionaries, from the upper ground, easily broke the mass-formation of the enemy by a volley of javelins, and, when it was scattered, drew their swords and charged. The Gauls were greatly encumbered for the fight because several of their shields would be pierced and fastened together by a single javelin-cast; and as the iron became bent, they could not pluck it forth, nor fight handily with the left arm encumbered. Therefore many of them preferred, after continued shaking of the arm, to cast off the shield and so to fight bare-bodied. At length, worn out with wounds, they began to retreat, retiring towards a height about a mile away.
That Caesar says this could occur might suggest that in warfare where javelin-throwing was very common, such as in the Western Mediterranean, an unfortunate solder/warrior could have their shield transfixed and have it weighed down enough for it to no longer be useful. However, note that not all of the Helvetii chose to discard their shield: it was a personal preference whether one wanted to keep the shield, probably holding it lower, or drop it so they could attack more effectively. Perhaps also note that the legionaries in this instance were throwing their javelins from higher ground, making it easier for more ranks to throw javelins and with greater force. The significant impact it had on the Helvetii formation and their ability to use their shields in this instance may therefore not have been a typical occurrence.