Optimal thermoelectric figure of merit of a molecular junction