Can I omit the second "I" in the following sentence: "I wanted to have another serving but somehow I restrained myself."
Yes, you can omit the second "I." It is grammatically correct to say "I wanted [first verb] to have another serving but [conjunction] restrained [second verb] myself. You would merely be creating a compound verb.
If you were to keep the second "I," you would need a comma between "serving" and "but" because there would be two complete thoughts.