Is there a way to participate in research, when I am no longer a student?
The first step in getting a recommendation letter is to ask for one from prior instructors. It is best to do this in person if it has been a long time, as you may not be remembered by name. But you might be surprised - especially if you were a hard working student back when. This is harder, of course, if you studied at an especially large institution where you had little actual contact with professors. In that case your contact would need to include reminders of who you are and of why some professor might remember you. At such a place, even after four years, it isn't impossible that an old TA is still around to help you. 

The more direct answer of course, is that you can, indeed, get connected to a research group to help them. But be upfront with the PI that you are trying to build reputation in order to advance your education later. 

The best way, again, to make contact is in person, which implies that you can travel to talk to people. Their work is probably public knowledge, so some research on your part can help you avoid obviously bad fits. If you want to provide primarily programming backup to a research group you may not need to actually sit with them in real space-time, but the initial contact should be face to face, perhaps with a chance to get to meet all the participants so that you can both explain what services you can provide and assure them you are capable of it. Thereafter, it may be possible for you to work remotely. But if all of their meetings are face to face you may need to deal with that also, at least periodically. 

An additional benefit of what you suggest to do is that you will invariably learn something about whatever research they are engaged in. That can only help your future educational opportunities, even if you study something different. 

There are no ethical concerns here. If you do good work for someone and ask them to recommend you for something related to your work it is all good.