Oil gained as fresh fighting flared up in the Middle East, and the US signaled increased economic pressure against Iran’s trading partners.