I would be surprised if Colbert's ask was truly impromptu given that hosts and a producer go through appearances with guests in advance. That it all seems off the cuff and in the moment is what good hosts do.
Plus, since Colbert himself has performed Sondheim I don't think he would put a guest on the spot like that or not let Scherzinger sing with the band if she had interest in doing so.