How does a spinning object “know” that it is spinning?
In short: because it can "feel" it.
What does spinning mean for an extended object? If we consider the extended object as a bound system of elementary ones then it is spinning whenever it is able to maintain its cohesion (its shape) while its elementary parts all want to well, part.
To see this, imagine you have a magic switch able to cancel all cohesive forces in a wheel. If the wheel is not rotating, you can toggle that switch on and off and will not observe any change. But if its spinning, then once you turn cohesion off you will see the wheel disintegrate, each of its parts going away in a straight line, in inertial motion.
Yet, consider the whole disintegrating cloud of elementary parts: its angular momentum is unchanged: it is still spinning, in a sense. See this related answer of mine for a more detailed, and quite relevant, discussion,.
Angular momentum is conserved for any group of inertial subsystems, bound or unbound. That is what rotational inertia really amounts to: conservation of angular momentum. But when analysed as above (and again, here), rotational inertia is only another expression of plain inertia; it is not another phenomenon. Add cohesion to an ensemble of elementary objects, and the overall effect of their inertia will be the spinning of the overall, bound, system.
What is important here is that it does not matter what boundary we give to a spinning system. Conservation of angular momentum applies to any arbitrary system of parts. Seen this way, Newton's bucket is in fact spinning relatively to itself. If you turn the magic toggle on, all the molecules in the bucket will move their own way, and the bucket will disperse; so the bucket "knows" it is spinning because its cohesive forces have to fight that dispersion (the most visible end result of this fight being the concavity of the water surface).
What about Mach's principle then? Well it seems to me that the question of whether space is absolute or not was in fact never what Newton's bucket is about. Spinning is absolute but there is no need to invoke distant galaxies or space itself. Newton's bucket does not need any referencial framework outside its own structure as a bounded object. It is because it is bounded that, when it is made to spin, plain Galilean inertia causes the reaction of cohesive forces to change some of its structure (shape of water surface, but also pression against its wall).
The trick is that considering a complex bound system like a bucket half-filled with water makes it very visible and clear that something is happening between inertia and structural integrity. This makes strikingly clear that spinning is absolute. But while it is absolute in the sense that it does not depend on a frame of reference, it is also local and relative to a well-defined system. Would the same bucket with no internal cohesion, an ever-expanding cloud of particles still maintaing its overall angular momentum, lead to the same speculations about the absoluteness of space? Which part of the cloud would we ask how it knows the cloud is spinning? None of those parts would feel that spin. It is only our arbitrary definition of the overall system that gives a meaning to the question "does it spin?".
So my final answer is in two parts:
an inertial object devoid of internal structure does not ever spin (at least in a classical sense - quantum mechanics does take this notion to the next level).
the reaction of internal cohesion to fragmentation via inertia is what makes an object "feel" that it is spinning.
Taking 2) at the scale of a whole planet, "cohesion" includes all possible planet-wide internal interactions and "fragmentation" all types of stress. A Foucault pendulum is then one of the ways to "feel" the rotation - as a part of the spinning system, it conveys the feel to another part of the system, the experimenter.