I just noticed that you originally asked about EU countries in general, and not only about the Schengen area. You have to distinguish between different situations.
Inside the Schengen area
I doubt it's possible to get a stamp when traveling between Schengen countries. I cannot guarantee that it never ever happens and I realize it's not a very satisfying answer but I still think I can justify this conclusion. The thing is that, to my knowledge, EU rules do not explicitly forbid it (national rules or procedures might) but which stamp would you get exactly?
Becoming part of the Schengen areas requires many changes, including the introduction of external border controls following the rules defined in the Schengen Borders code. Schengen states therefore have to provide their border guards with a special set of stamps and have no reason to use older stamps they might have used before.
Clearly, standard Schengen stamps should only be used at external borders. Their use is regulated in details in the Borders Code, each of them have to be traceable to a given control point and border guard (not necessarily one stamp per person but at least some list of who had what stamp at which time) and correct use is essential to enforce the limits on duration of stay. So that's not something to play with and if you manage to find a police agent near an internal border, he or she won't have one on hand or will have been instructed not to use it.
Which means that reliably getting stamps at internal borders would require Schengen countries to issue an entirely separate set of vanity stamps solely to entertain tourists crossing a border they are not supposed to patrol in the first place. I guess you might stumble on someone who still has an old stamp or something but I don't think it's likely to happen in many places.
Between non-Schengen EU countries
As far as immigration is concerned, border checks between non-Schengen EU countries are in all respect similar to border checks between an EU country and a non-EU country (customs is a different matter). There are special rules for EU citizens and their family but they apply no matter where they presently come from.
For example when entering the Schengen area from the UK, getting a stamp is not only possible but mandatory for third-country nationals who do not reside in the EU (with very few exceptions like seamen, aircrew, or heads of state on official business). But third country nationals who reside in the EU as part of the family of an EU citizen (and travelling with the special residence card proving their status) should not get a stamp anywhere in the Schengen area, even if they are, say, transiting between non-EU destinations.
@walter describes an instance where a proper Schengen exit stamp was applied when leaving France for the Netherlands (both Schengen). It was clearly a case of border guards performing a full external check (which is what they would otherwise do at an airport serving non-Schengen destinations). That's also why they would have Schengen stamps on hand.
There are several micro-states landlocked within the Schengen area. Formally, they are not a member of anything (not even the EU so technically that could be considered outside the scope of your question) and they do whatever they want (including applying stamps to your passport). Theoretically, this would seem to imply that Italian (or French and Spanish in the case of Andorra) police should patrol the border, stamp everyone in and out, check that you really have a multiple-entry visa to reenter, etc.
In practice, it's not really the case. Some external borders are notorious for a (sometimes deliberately) lax application of the rules, e.g. Gibraltar and this occasionally creates problems (people having trouble proving they haven't stayed too long or account for a missing stamp). As far as I can recall, the border with Switzerland was also like that before the country joined the Schengen area (travellers at major airports, on motorways and in long-distance trains still underwent full border checks but many roads and even some regional trains were effectively open with a sign warning you not to cross the border if you were not allowed to do it, which would include any situation in which you need a stamp).
That's not really interesting to you as you want extra stamps and are not trying to avoid them but this explains why you could easily get one in San Marino even though it feels as if it's part of the EU and Schengen area.