WASHINGTON—President Trump revived an idea of relocating detained immigrants to so-called sanctuary cities, signaling he is considering previously discarded options amid his growing frustration over the flow of Central American families seeking asylum at the southern U.S. border.

Mr. Trump’s comments, which also marked a new shot at his political opponents, came after a week in which many top leaders at the Department of Homeland Security were ousted. The president has been working with advisers including Stephen Miller to...