Nearly! It should be "Can you imagine how terrible he/she can be?"
There's actually two questions here, which are "Can you imagine ...?" and "How terrible can he/she be?". When you nest the latter in the former, it becomes a reported question, and you have to invert the word order for those.