This exact scenario is why I created the mod linked above. With it, you can set the angle of an engine gimbal like this:
engine:GetModule("ModuleGimbalTrim"):SetField("Gimbal X", angleX).
engine:GetModule("ModuleGimbalTrim"):SetField("Gimbal Y", angleY).
Note that the mod's X and Y fields do not necessarily correspond with the X and Y axes of engine:facing. You can figure out which way the gimbal rotates (this varies depending on the engine) and then just rotate the engine accordingly in the VAB.