Yes, you can sacrifice a creature to an altar (such as Ashnod's Altar or Altar of Dementia) after blockers are declared but before combat damage is dealt. The combat phase has multiple steps, and players receive priority between each step.
After the Declare Blockers Step concludes (CR 509.5), the game moves to the Combat Damage Step, but before damage is actually assigned, both players receive priority in the Begin Combat Damage Step (CR 510.1). During this priority window, any player may cast spells or activate abilities, including sacrificing creatures to altars.
This is a common tactical play. For example, if your 2/2 creature is blocked by an opponent's 3/3, you can sacrifice your 2/2 to Ashnod's Altar in response before combat damage is dealt. Your creature never takes lethal damage, you gain 2 colorless mana, and the opponent's 3/3 deals no damage since its assigned blocker is gone. Note the opponent's creature will still be 'blocked' — the attacking creature does not become unblocked (CR 509.1h).
Also note that if there are multiple attackers and you want to sacrifice one specific creature, the order in which you act matters. You have full flexibility during the priority window before damage assignment to activate mana abilities or sacrifice outlets.
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.