Yes, you can sacrifice a creature to pay a cost even after it has been declared as a blocker. Being declared as a blocker does not lock the creature in place or prevent it from being sacrificed. CR 509.1 describes the declaration of blockers, and nothing in that process creates a restriction on sacrificing a blocking creature.
When a creature is sacrificed, it is put into the graveyard as a state-based action consequence of the sacrifice cost being paid. The creature is simply removed from combat (CR 506.4). The attacker it was blocking is now unblocked — but crucially, once a creature has been declared as a blocker, the attacking creature remains 'blocked' for damage assignment purposes even if the blocker leaves combat (CR 509.1h). So the attacking creature will not deal combat damage to the defending player.
This matters a great deal: the attacker is still considered blocked and will deal no damage to the opponent unless it has trample. A creature with trample would assign lethal damage to the now-missing blocker (0, since it's gone) and the rest to the player, but without trample, damage is simply not dealt (CR 702.19b).
Concrete example: Your opponent attacks with a 5/5. You declare your 2/2 as a blocker. Before the Declare Blockers step ends, you activate an ability requiring you to sacrifice a creature, sacrificing your 2/2. The 5/5 is still considered blocked. Unless it has trample, it deals no combat damage to you this turn.
This is a common combat trick — sacrificing a blocking creature to activate an ability while denying the attacker from hitting you directly (absent trample).
Unofficial fan resource — not affiliated with or endorsed by Wizards of the Coast. Answers are AI-generated estimates grounded in the Comprehensive Rules and are not a substitute for an official judge. Verify anything match-critical.