It sounds like a problem with the swim bladder.
If it is a fancy goldfish IE with longer than normal fins or very deep in the body with an unnaturally shaped tail, then it is a genetic problem of which fancy goldfish are very prone to.(nothing can be done)
Or the swim bladder has an infection.
Besides keeping it in warm water for the rest of its life, there is nothing of use that can be done.(problem is that if it is to be returned to its normal environment, the problem will likely reoccur)
If it was mine, I Would overdose it with anaesthetic to put it out of its misery.