Answer to this question is simple: yes. You can be fired if your employer learns that you’re using medical marijuana because it’s illegal substance.
And just because it’s legal in some states doesn’t change fact that it’s still illegal under federal law. Employers are allowed to fire you for using medical marijuana without any consequences.