The U.S. and Britain banned passengers from carrying most electronics larger than a cellphone into the cabin on flights from a handful of countries in the Middle East and North Africa, responding to what American officials described as a terrorist threat to global aviation.