When you declare attackers (CR 508.1), each chosen creature becomes an attacking creature and, unless it has vigilance, is tapped as part of that declaration. More importantly, it is now legally an 'attacking creature' assigned to a defending player or planeswalker.
Sacrificing a permanent removes it from the battlefield entirely (CR 701.17a). If you sacrifice a creature before the Declare Attackers step, it no longer exists and cannot be declared as an attacker. If you declare it as an attacker first, it is already committed to the attack — and then if you sacrifice it (e.g., to pay an activated ability's cost during combat), it leaves the battlefield, removing it from combat (CR 506.4). It cannot serve both roles simultaneously because one action must precede the other in time.
There is no game rule that lets a single creature occupy both the 'attacking creature' zone-role and be sacrificed in the same instant. Costs are paid before effects happen (CR 601.2h), so you would have to sacrifice it before it could attack, or attack with it before you sacrifice it — never both.
Concrete example: You control a 2/2 Grizzly Bears and want to attack with it AND sacrifice it to Ashnod's Altar for 2 colorless mana. You must choose: either sacrifice it before declaring attackers (gaining the mana but losing the attacker), or attack with it and then sacrifice it during combat (gaining the mana, but the creature is already gone and deals no combat damage).
In short, the two actions are mutually exclusive in achieving both goals — you can do them in sequence, but the creature cannot simultaneously count as an attacker dealing damage and be sacrificed as a cost.
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.