You can get ESA whilst still in work, although you may rather absurdly find yourself going through the annoyance of Work Focussed Interviews despite the fact that you already have a job.
There are protections against being sacked where you are disabled, but it is possible to sack someone on capacity grounds, i.e. where they are not capable (even with reasonable adjustments) of doing their job. However, this is another area on which we do not advise. See here for information on your rights -
www.equalityhumanrights.com/advice-and-g...uality-act-guidance/ If your employer threatens to sack you or sacks you, get prompt face-to-face advice. CABx advise on employment rights, and you could also contact the CLS. There may be other advisers in your area that can help.
If you are a member of MDF the BiPolar Organisation, they have a free employment advice service.