It will be impermissible to work for the MI5 if it requires the person to cause harm to the Muslim community or individuals, be it directly or indirectly. Conversely if the job does not affect Muslims it will be allowed although inadvisable and as such should be avoided. and Allah Ta'ala knows best.