Yes, idioms can be used in formal contexts depending on the specific idiom. Some idioms are universally understood and can be used in formal writing or speech.