Thousands of Iraqis have signed a pledge to help defend Iran in the event of a US attack on the Islamic Republic.