If you have to ask, then probably not.
Idioms are not the same as slang; they can be used in formal, academic writing--sometimes. It is very difficult for non-native speakers to accurately gauge tone, and therefore you risk sounding too informal. I would recommend you avoid idioms in formal writing for now.
Student or Learner