Yes, "that sucks" is extremely informal, usually used by younger people, and the previous person who answered is right--it takes great cultural sensitivity to know how and when to use it, and with whom! When you learn a language, I feel like it is important to know what slang means, but I don't advise on using it yourself, unless you have a very very high level of the language.
A safer response would be "Oh no." or "Wow, that's too bad." I would personally respond, "Oh no, are you feeling better?/How are you doing?"