...I'm just going to drop my oar back in.
The Captain of the Constellation attempted to sacrifice it and himself. He failed.
No he didn't. His ship was immobilized with minimal life support and he evacuated his crew to the surface of the third planet, which was subsequently eaten by the planet killer. Constellation was in essentially the same condition as the Shenzhou.
But Decker didn't destroy the Constellation. Why?
The Stargazer was wrecked, and lost.
And abandoned for years, after which it was recovered by the Ferengi and deliberately used against Starfleet in an ill-conceived plot to destroy the Enterprise. It's actually WORSE than the Shenzhou since the entire ship was actually used against Starfleet and not just a salvaged engine component.
Regardless, Picard didn't destroy the Stargazer. Why?
The Hathaway was an old ship brought out of storage for war games.
Hathaway was an old ship, but we're never told what it was doing in the Braslota system, or how the Zackdorn acquired it. Or IF the Zackdorn acquired it, rather than simply FOUND it drifting abandoned in orbit of that planet.
At any rate, we're still forced to wonder why Picard and/or Riker chose to gamble on some sort of longshot ploy rather than simply abandon the ship and destroy it. Evidently even an 80 year old hulk is worth risking the lives of 40 crewmembers to make sure they recover it intact.
The Enterprise D...unknown, but I think we could safely assume it was removed from the planet, and not just left there to rot.
Eventually, sure. Just not by the ships that recovered the survivors. That was covered by one of the Shatnerverse novels, IIRC. But Picard's final log entry only laments that the Enterprise will never be salvaged, NOT that he will have to plant demolition charges to blow up the ship before anyone finds it. Why is that?
With the same basic result and the same final conclusion:
Starfleet does not sanitize its leftover equipment to prevent capture by "the enemy." They try to RECOVER their equipment whenever it is practical to do so, or wait until conditions arise as such recovery becomes possible.
Now, if we want to talk about Starfleet's actual policy in such situations, we need to look no further than The Pegasus:
PRESSMAN: However, all that changed three days ago. Starfleet Intelligence has an operative in Romulan High Command. He sent us a message that a Romulan warbird had located a piece of debris in the Devolin system which was positively identified as being from the Pegasus. The warbird was then ordered to locate the rest of the ship, if possible, and retrieve it.
LAFORGE: What would the Romulans want with pieces of a twelve year old starship?
PRESSMAN: The Pegasus was a prototype. Experimental engine, new weapon systems. In fact, some of our designs were used in constructing the Enterprise. There are a lot of things on board the Romulans would love to get their hands on.
PICARD: What are our orders?
PRESSMAN: To find the ship before the Romulans do. Salvage it if possible, destroy it if necessary. You command the Enterprise while I remain in command of the overall mission.
Later:
RIKER: I recommend we destroy the asteroid. It would take most of our photon torpedoes, but it would preclude any possibility of the Pegasus falling into Romulan hands.
PRESSMAN: Our top priority is to salvage the ship, Commander. I'll consider destroying it only as a last resort.
RIKER: Yes, sir.
This for a "prototype" starship that has Starfleet's revolutionary new phase cloaking device on it, and Pressman is saying that salvage is STILL their top priority.
Shenzhou is a good ship, but it's no Pegasus, and it sure as hell isn't equipped with a Starfleet cloaking device. There's nothing on that ship that would give the Klingons any more insight into Starfleet technology they don't already have; hell, it's considerably older than the twelve years the Pegasus was supposed to have had, with some of its components already obsolete. So we should expect that demolition of the ship to keep it out of "enemy hands" is something Starfleet would consider if and only if there was a real fear that capture would cause problems for Starfleet.
As discussed at some length above, there is ZERO reason to believe this is the case. And to backtrack further, this is equally true of the Constellation, the Enterprise-D and the Stargazer. Starfleet did not forsee that Damon Bok would eventually use Stargazer against Picard, nor would they consider that remote possibility justified in the case of Constellation or even Hathaway. On the other hand, James T. Kirk was charged with "Willful destruction of Federation property" for blowing up the Enterprise in the middle of a Klingon boarding party; evidently, the fact that the ship was disabled made self-destruct an act of desire instead of necessity and was therefore a major violation of Starfleet regulations.
They are not nearly identical circumstances.
In the case of Stargazer, they are EXACTLY identical circumstances. In fact, I would bet that the time it took for Bok to learn of his son's death and come looking for him only to find a derelict alien vessel of unknown origin floating in space with battle damage... was probably somewhere on the order of six months. So it's not identical, it's actually a lot worse.
Constellation's case is nearly identical if only because we know in hindsight that there was nothing on the doomsday machine that would have tried to salvage the ship for parts. But Decker didn't know that, nor could he have counted on someone like the Klingons or the Romulans stumbling upon his wrecked vessel in the asteroid field six months later. That still wasn't good enough reason for him to rig his ship to self-destruct, though, which evidently wouldn't have been all that hard to do.
tl;dr: the facts speak to the pattern that has been fairly consistent: whenever the captain judges that the prospect of capture poses a great enough risk, the ship is destroyed to mitigate that risk. In Shenzhou's case, the risk was non-existent, as even the salvaging of parts wouldn't be necessary for anyone who actually MATTERED in the Klingon war effort.