Here's a minor variant on Margaux's comment from a year ago. Let $S = \mathbb{A}^2$ (say, over your favorite field), and let $\pi: G \to S$ be the constant $S$-group scheme $(\mathbb{Z}/2\mathbb{Z})_S$. As a scheme, it is a disjoint union of two copies of $S$.
If we remove a point $g$ from the non-identity section, we get an $S$-group scheme $G - g$, whose underlying scheme is a disjoint union of $S$ and $S - \pi(g)$ (note that $(G-g) \times_S (G-g)$ is a disjoint union of an identity section $S$ and 3 copies of $S - \pi(g)$). This is not affine over $S$, since $S$ is affine and $G - g$ is not.