Leviticus 26

Leviticus 26:24

"I also will walk with you with a perverse spirit, and I also will strike you seven times for your sins."
Does this passage endorse cannibalism?

By definition, an "advocation" constitutes an approval or an endorsement. These verses do not prescribe cannibalism as an acceptable practice. They do predict what will happen as a judgment upon sin after an extended period of warnings and lesser judgments (so there can be no excuse of blaming God for these actions).

When evaluating these judgments, one must consider the historical context of the average Ancient Near East inhabitant who had to scrape to survive. In extreme siege conditions, individuals resorted to desperate measures for the preservation of life, similar to modern instances where survivors of extreme disasters have eaten human remains to live. The Bible is predicting the horrific natural consequences and judgments of siege warfare, not endorsing cannibalism as a moral good.