WASHINGTON—President Trump on Thursday canceled a trip to the World Economic Forum summit in Davos, Switzerland, and reasserted his willingness to declare a national emergency to pay for the border wall as the partial government shutdown neared the longest in history.

“Probably I will do it, I would almost say definitely,” Mr. Trump said when asked whether he would consider declaring the emergency.

Mr....