So, there are two mechanical solutions to, what is, fundamentally social problem, but before I provide them, I want to make clear that employing these is an easy way to be regarded as a jerk by your fellow passengers, and not without merit; the seat is designed to recline, and while putting it back can be inconsiderate, restricting the use of the feature by others can be just as inconsiderate on a long flight. Think long and hard about just how much of an asshole you are willing to be before attempting to block the passenger in front of you from taking what small comfort they can in the horrid conditions found in coach class on a commercial airliner.
First, the commercial solution: The Knee Defender. A small device that clips onto the arms supporting the tray table, when the clip is in place, the seat in front of you is unable to recline. It can be adjusted to allow for limited recline, if you're feeling considerate, but the 'courtesy card' provided by the manufacturer should be pretty clear evidence that this is inherently a pretty inconsiderate product.
If, in addition to being a jerk, you're also a cheapskate, you might want to look into using a water bottle or other, similarly sized rigid object as a shim to prevent the seat in front of you from reclining. Like the Knee Defender, this has the downside of requiring that you keep your tray table down to rescue your precious legroom, and, unlike the Knee Defender, also will take up some space on the tray table, which may or may not bother you. It is similarly inconsiderate to use.
Alternately, you could be less of a jerk, and pay the often pretty nominal premium to get a bulkhead facing/exit row seat, where nobody is in front of you to recline.