Getting the rightmost zero is easy: ~x & (x + 1)
Using that, you can do this in a couple of easy steps: (not tested)
uint32_t rightmost_zero = ~x & (x + 1);
uint32_t result = (x | rightmost_zero) & ~(rightmost_zero << 1);
There may be a simpler/faster way.