If someone gifts me something like a cake and I send the cake to another person , is it wrong in Islam? I don't mean to hurt anyone. Also can you use a gift in a way the other person you think wouldn't like, for example I sold a phone my grandfather gave.
It isn't necessarily wrong to send a gift someone sent you to someone else.
For instance you might have used the phone your grandfather gave you, and later you give it away. Your grandfather would have understood because he knows that the phone he gave you is getting old.
It might be meritous if you give the cake to a needy person who doesn't have anything to eat. However if the person who gave you the cake heard about it, He might get hurt. So its advisable to give the cake away without the knowledge of the person who sent it to you.
You must be your own judge. Wisdom cannot be taught like knowledge; it must be acquired through experience. Do what is right.
Allah knows best.