I've been thinking about this since the recent article where a NASA JPL US citizen employee was detained and forced to give up his password.
I have a Chromebook. It's easy to wipe it completely to fresh out of the box factory settings. At the border, you can give them a completely blank computer. (or set up a dummy Chromebook account with nothing on it). Then when you are back safely in the US, just enter your credentials and it will download everything from the cloud and you're back in business.
Phones are a little more difficult. You can factory reset these but your SIM card still has data. You'd need to install a decoy SIM card in it (preferably a burner SIM from some odd place where it won't work in the US). You'll have to deal with your own SIM card by hiding it or mailing it to yourself. Once you reinstall your original SIM and login, the phone apps, etc. will restore themselves.
Either that or just buy a burner phone and ditch it before you return.