HANOI — A Vietnamese shipping firm paid more than $2 million in ransom to free its crewmen held for months by Somali pirates, a company executive said after the sailors arrived home.