Probably Not
The human body, naturally, contains all the basic nutrients a human needs to survive. So as long as you're careful to eat all of it (grind up the bone to put in sausages, drink/use the blood in cooking, eat most of the organs) you'll get everything you need from cannibalism to survive. It might not be the perfect diet, I'm not an expert in all the vitamins and minerals a human needs to know if there's Some Specific Thing which you'll be somewhat deficient in if you only eat people which might lead to long-term complications. But the diet will be at least as "healthy" as a normal medieval diet.
That being said, how many corpses would you need? James Cole estimates an adult human body contains on average 125,822 calories. Source Caloric consumption for an adult human is roughly 2,000 calories a day. (Cole believes that a modern human's average need is 2,4000 calories a day. Not sure why, so I'm sticking with 2,000 as the more widely-accepted figure.) That implies a single human body could feed 62.9 people for a day. Of course there's going to be "wastage" in the corpse as you're unlikely to eat 100% of it. Assuming 15% wastage (loss of caloric value from spilled blood/missing bits from hacking your victim to death outside the walls, etc) means your average corpse feeds 53 people a day. Call it 50 in round numbers. So for every 50 defenders in your castle, you need to kill one attacker every day AND recover the corpse. Of course, you might not get "just" humans in your attack. I couldn't find a full-body caloric assessment, but just the muscle mass of a horse yields 359,100 calories. Assuming that's the maximum value you can get (medieval horses were smaller, there's some wastage which may or may not offset whatever added caloric value the blood and bones get you) a horse can feed about 179 people a day. But as cavalry aren't really "storm the walls" troops, you can't rely on the enemy keeping horses anywhere near enough for you to snag. So the question becomes, can the defenders achieve a kill ratio of 1 attacker per day for every 50 defenders?
I believe the answer is a firm "No." Assuming the enemy has 2x the amount of men as the defenders (Since 2x would preclude the defenders just sallying out en-mass but is less than the 3x generally thought sufficient to storm a fortified position with a chance of success) That would involve inflicting More than 1% casualties on the enemy every day for as long as you need to live purely off human flesh. Sieges were long, drawn out affairs. The enemy likely will keep out of bowshot most of the time, relying on starvation to take its toll. This means any sally for "provisions" will require a force from the castle going at least 100 yards (and likely longer, depending on your bow tech) from the castle, into the enemy camp, killing some of them, and then dragging the bodies back. The dragging back is the killer here. I can see a vicious and aggressive besieging force launching tons of attacks, and POSSIBLY inflicting a kill per 50 every day. But you have to get the body back, as intact as possible. At some point your enemy will realize you're literally eating him and do everything in his power to stop you.
Unless you're some sort of horror cult that cannibalizes in peacetime, they'll know you're low on food. The attacker will simply pull back even further, fortify the siege lines even more heavily, and fight like hell to protect their dead from desecration. Which means you won't recover every corpse. Which means you need to kill even MORE of the enemy. As a 1% daily attrition rate would end the siege in a max of 80 days (the point where your besieged force significantly outnumbered the attackers that started 2x the size) Killing even MORE of them makes the whole concept of your defenders being besieged to the point they need to eat the enemy dead redundant.
You can offset this somewhat by the defenders eating their own dead as well, but that leads to diminishing returns. A starving person is a lot fewer calories than a healthy one, and likely deficient in key nutrients that would cascade as anyone eating them wouldn't get those nutrients from the corpse. Though I admit I'm not sure how long one could live eating your own dead while "augmenting" any missing nutrients from enemy corpses, the end result still seems like you'd need to many deaths to keep the siege viable, one way or the other.