Can I get in trouble for telling my work I am leaving?

Give notice. If you give proper notice, then you should be fine. Please don't be a "no show, no call" employee. Leave on good terms. Is there a medical issue that prompted you to ask that question on a medical forum?