The army general who led the overthrow of Thailand’s elected government in May was named prime minister on Thursday by a rubber-stamp legislature, sealing the military’s acquisition of near-absolute power in a country once considered a regional beacon of political freedom.