Yes, the phrase might as well can be used in a formal context. You can also use the phrase may as well in a more formal setting.