"Hey Mr. Border Guard, this is a burner phone, have at it!"
"Okay can you login to your email for me? If not I'm going to have to keep you here until you do."
You have to set up trivial, low value “burner” email that you use for your emailing activity when overseas, and other related social media accounts, and make sure to keep them “warm”.
A spare old Pixel or iPhone SE is $20-$50 you can use for this purpose.
If you’re talking about a US citizen returning home, they can’t hold you indefinitely. If you disagree, I challenge you to find a counter example.
All bets are off if you’re a non-citizen entering another country, it depends on the laws and customs there.