Unfortunately, once the stem or leaves start to yellow, they are very unlikely to recover, even if the growing conditions improve.
But the plant is not necessarily lost. You have two options.
The botanical name for "lucky bamboo" is Dracaena sanderiana (commonly referred to as a Dracaena plant). If this a larger, mature plant with multiple side shoots, you can prune off the individual yellowed leaves or the entire side shoot (if the stem itself is turning yellow), and that should stimulate new growth and recover nicely.
But if this is still a young plant (as pictured below), you will want to cut off the yellowed parts, possibly starting a new plant.

Propagating Lucky Bamboo
Propagating a lucky bamboo is easy.
- Select a stalk for propagating. Select a stem that has the most healthy green growth at the top and cut it off cleanly with a sharp knife or pruning scissors. Make sure you don't include any of the yellowing stem. You want to cut through the healthy green part of the plant an inch or two below one of the ring segments encircling the stem.
- Remove the bottom leaves. From your stem cutting, leave only a few mature leaves at the top of the shoot. You want all the energy of the plant going into growing new roots, not supporting excessive foliage.
- Place the cutting in soil or water. Lucky bamboo cuttings can be rooted in either water or soil; I've had better luck starting with water, then transplanting it once the roots have developed. Push the stem into the soil/water about 1-2 inches, making sure at least 1-2 of the growing segments are submerged (this is where the roots will sprout from). If you use soil, keep it constantly moist (don't let it dry out). If you use water, change the water often to avoid it becoming stagnant. In 1-2 months, the plant should have developed several roots from the cut end and you can decide what to do with it from there.
- Transplant as desired. Some people leave their lucky bamboo growing in water indefinitely. This is mostly an an aesthetic preference grown mostly for the temporary novelty of it. The rooted plant will eventually grow new shoots and you can propagated it again and again using the same method. But if you want the strongest possible plant, you will eventually need to transplant it to grow into a larger potted specimen. Regular garden soil will be fine. Keep it most (but not wet). Dracaena can take shade to bright light, but keep it out of direct sunlight; it will tend to burn the plant.