Giving medicine in bottle?

My 5 month old just will not take his cough medicine. He spits it all all over the place. I don't know exactly how much he actually swallows, so I'm not gonna be giving it to him over and over again. Is it OK to give him his medicine in his formula? Ftm here.