Can I work out or go to work right after my endoscopy?

Talk to doctor. This would be best directed to the doctor doing your procedure.
Post-sedation. You must avoid driving, work, decision making or doing anything at risk until at least the following day. Midazolam or other meds do affect concentration and recall following the procedure.