Well guys we always see this kind of situation. Let me tell what I think and my little experience tells me based on the modus operandi of legal forces.
Here were I live, hospice country, police for some kind of investigation get your phone. They first kindly ask for you to give them the code and they will make pressure telling you will be arrested and blablabla.
You have 3 options
1- if you have personal data that don't compromise you more than your personal things give them the code... They have in many cases a specific search warrant that won't cover everything that they find(in most cases). They cannot change the investigation object but they can create a new one if you have complicated things inside you phone.
2- NEVER NEVER CLEAR YOUR PHONE.they will accuse of destroying evidences which is not necessarily truth but it will mess with you. No one would destroy data without being afraid of finding something important there
3- if you choose not sharing let them struggle to get the data. They can even get you arrested but they can't sustain and a lawyer can work on this very fast taking you out. But be careful because if you are truly involved in something they don't kick your door randomly... They have enough information to trust you are involved in some situation.
Make a calculation a simple one: which worth more give the code with absolutely sensitive information that will lock you in jail forever or the information there that will be discovered (which possibly will be because there are other actors involved that possibly has parts of the information you have and they can put everything together and accuse you anyway.) Or if not you will get caught they won't prove nothing and you are out. But be careful, they are smart and they have many other fonts that they can joint and get you anyway.
Despite all above the best thing is: don't get involved in trouble to don't have to pass this humiliation. Don't ever stay in debt with the state. They can do whatever they want with you. So follow the law, use the system because you want security for your personal things and avoid hacking and live your life making sure when you put your head in the pillow you can sleep without worries. Life is too short to make things wrong and pay a high price in life for going in wrong paths.