>>508592123It doesn't happen to most travelers, in large part just because of the massive time investment, but it absolutely is a thing that they have the ability and legal right to do.
I used to work for Customs and Border Protection, and while this wasn't something I did personally it was something our team heard a lot about. You basically have to already be flagged for secondary inspection for this to happen to you, which means that the guy in the OP was *probably* detained and denied entry for reasons unrelated to the meme, because they wouldn't have even been looking at his phone unless he already triggered some kind of watchlist.
But yes, they can search and copy your phone. Just be aware thats a thing that can happen.