I think if you called it it a 'suggested donation' of 'a quid or so' (or 'a couple of quid' - word it carefully to get the amount you would like) to cover the costs involved, most people would happily give you some money, and since you are not selling it to make a profit just wanting cover your costs you would probably be ok legally. As others have said, I think this is more to deter people who grow to sell commercially rather than to friends. I think it would be different if you were to sell it at a car boot sale or market stall, for example.
It is a bit of a legal grey area, but I doubt they would go to the effort of prosecuting you if they happend to catch you, as firstly it would probably not be in the public interest, secondly the amounts involved sound like they are fairly small, and also you could argue that you were not selling the produce part of the jam at all, just covering the cost of (or even making a profit from) the other ingredients, your time, electricity/gas and the jar. (I have been looking for jars to make jam recently and am amazed at the price of them! Sainsburys basics 4p curry sauce and 15p mint sauce work out a lot cheaper, even if you bin the sauce!)
Perhaps you could also put a note on the label about returning the jar, and donating any others they happen to have which would otherwise go in the recycling bin. I have also had some success with asking for jars on Freecycle.
I wish we had enough fruit from our allotment to make jam - the only fruit we have had enough of so far (it is our first year) is blackberries from the existing brambles on the site! We have of course made several jars of jam and jelly from it already, and may make a few more if we get time to pick this weekend. Other jam experiments have mostly been made from squishy marked down fruit at the supermarket or market stalls, and from a 'pick your own' farm we visited. (The fruit worked out very reasonable and it was a fun day out. I would recommend it!)