Attach 2x4 to a warping 2x4 wood rail?
You could screw up through the lower 2x4 into the top 2x4, such that the screw heads would be on the bottom of the lower board and not seen from the top.

But I think there's a different question here: Why reinforce the existing board?

When working on problems like this, I first try to determine the root cause of the problem. Did that 2x4 warp because a 2x4 is not sufficient for that purpose? Or did it warp because the original board was poorly selected (it had a big knot, or gnarly grain).

If a 2x4 is indeed sufficient, then why not just replace the original board, instead of trying to "correct" it with a reinforcement?

If a 2x4 is not sufficient, then how about replacing with a correctly-sized piece of lumber instead of reinforcing the existing board?

In other words, reinforcing the existing board would be low on my list of choices.