Two examples that I can think are:
$\Rightarrow$ A person in Delhi contributing money for the construction of a well in Nairobi
$\Rightarrow$ A person spending time at a teaching programme for underprivileged kids (instead of money the budget line can be thought of in terms of time.)
In both these cases (and yours) the marginal gains are 0 for the agent in terms of the tangible goods but the fact that a rational agent will make these payments means that there is an intangible aspect of humanitarianism in the utility functions, say, $U(x,y,z) = (xy)^2 \sqrt{z}$ , where $x$ is the consumption of food, $y$ is the consumption of other goods than food and z is the amount contributed for a cause. So the consumer will solve:
$\underset{x,y,z}{Max}(xy)^2 \sqrt{z} $ subject to $ P_x (x) + y + z \leq M$
This explains why people make these contributions even after 0 tangible gains from them.