Lionel Messi came off the bench and scored a hat-trick as Inter Miami wrapped up the best regular season in Major League Soccer history.