I am hoping that there is a generalization of Birkhoff's theorem that applies not only to algebras (in the sense of Birkhoff's paper) but also to algebras that satisfy certain equational identities (such as cancellative semigroups).
There is a version of Birkhoff's Theorem that applies to quasivarieties, such as the quasivariety of cancellative semigroups, but it doesn't give you what you are asking for here. Namely, if $\mathcal{Q}$ is a quasivariety and $\mathbf{A}\in \mathcal{Q}$, then call $\theta$ a $\mathcal{Q}$-congruence on $\mathbf{A}$ if $\mathbf{A}/\theta\in \mathcal{Q}$. The $\mathcal{Q}$-congruences on $\mathbf{A}$ form an algebraic lattice, and that is enough for the '$\mathcal{Q}$-version' of Birkhoff's Theorem to hold: every algebra in $\mathcal{Q}$ is a subdirect product of '$\mathcal{Q}$-subdirectly irreducibles'. An algebra $\mathbf{S}\in \mathcal{Q}$ is $\mathcal{Q}$-subdirectly irreducible if it has a least nonzero $\mathcal{Q}$-congruence. In particular, every cancellative semigroup is a subdirect product of cancellative semigroups that are subdirectly irreducible relative to the class of cancellative semigroups.
But a $\mathcal{Q}$-subdirectly irreducible might not be subdirectly irreducible in the absolute sense, so this doesn't answer the question that you asked. [For example, if $\mathcal{Q}$ is the quasivariety of torsion-free abelian groups, then every member of $\mathcal{Q}$ is a subdirect product of $\mathcal{Q}$-subdirectly irreducibles. But no torsion-free abelian group is subdirectly irreducible in the absolute sense, so the members of $\mathcal{Q}$ are not subdirect products of (absolutely) subdirectly irreducible torsion-free abelian groups.]
Let me at least give an affirmative answer to the commutative version of your question.
Claim. If $S$ is a commutative cancellative group, then $S$ is a subdirect product of subdirectly irreducible cancellative semigroups. (In fact, $S$ is a subdirect product of subdirectly irreducible abelian groups considered as semigroups.)
Reasoning. Embed $S$ in its universal group $U$, which is an abelian group. For each $a\neq b$ in $S$ ($\subseteq U$), choose a group congruence $\theta$ on $U$ that is maximal for $(a,b)\notin \theta$. The group $U/\theta$ is a subdirectly irreducible abelian group, hence it is isomorphic to a subgroup of some Prüfer group $\mathbb Z_{p^{\infty}}$. The composite map $f_{a,b}\colon S\to U\to U/\theta\to \mathbb Z_{p^{\infty}}$ separates $a$ and $b$ and has image $f_{a,b}(S)$ that is a subsemigroup of $\mathbb Z_{p^{\infty}}$. Every subsemigroup of $\mathbb Z_{p^{\infty}}$ is a subdirectly irreducible group that is also subdirectly irreducible as a semigroup. Thus, $\prod f_{a,b}\colon S\to \prod f_{a,b}(S)$ represents $S$ as a subdirect product of subdirectly irreducible abelian groups. \\\
Edit. Let me respond to a request in the comments by giving a reference for the relative version of Birkhoff's Theorem. See Theorem 1.1 of
Finite basis theorems for relatively congruence-distributive quasivarieties
Don Pigozzi
Trans. Amer. Math. Soc. 310 (1988), 499-533.