Should the following say whoever or whomever. And why?
Each of us is free to pretend to be whoever/whomever we wish to be.
This sentence needs an object, right?
Whoever vs. whomever is basically the same problem as who vs. whom, and there are some who argue that the problem so baffles so many users of English that we may as well just give up on the objective forms with the m in them, and just use the forms without it in all contexts.
The problem and confusion tend to arise because these (as used here, at least) are relative pronouns, and a relative pronoun can sometimes seem to be at once an object and a subject:
Solon gave the responsibility and authority to launch a criminal prosecution to whoever so wills.
People are tempted to use the m form there because the relative appears to be (and indeed is) the object of the preposition to. But more importantly, and generally across multiple languages, the case of the relative is determined by its grammatical role within the relative clause, in this case as the subject of the verb wills; so subjective case is quite properly used. The tension will bother some users of English even so.
In your example, the relative may appear to be the object of both the verb be and the verb wish, so whomever is tempting. But be is rather a linking verb than a transitive one, and wish is elliptical for wish to be, so on both counts whoever should be preferred.
Some say using subjective (aka nominative) forms with be (including where it is thus elided), as in “it is I” or “He is taller than I [am],” is stuffy and pretentious and should be abandoned; but when the pronoun is who or whoever, the same objection is raised against the objective form in all contexts, so in this case the old-fashioned purist/prescriptivist and the go-with-the-flow evolutionist are actually likely to agree in preferring whoever.
I am interpreting this as a case where whom/whomever is not to be used for the following reasons, whereas much of modern English grammar advice would anyway echo John Lawler's comment that whom/whomever is never required.
(1) Who/whoever is a subject pronoun and whom/whomever is an object pronoun.
Who” and “whoever” are subjective pronouns; “whom” and “whomever” are in the objective case. That simply means that “who” (and the same for “whoever”) is always subject to a verb, and that “whom” (and the same for “whomever”) is always working as an object in a sentence.
This may be interpreted as follows: whom/whomever should be used only if there is the need for an object pronoun, and in all other cases (even as default in all cases, as highlighted in comments by grammar expert John Lawler) who/whoever is to be used.
(2) 'To be' is the basic form of is/am/was/were and therefore does not need a object.
In fact 'be' is a linking verb which
connects the subject with a word that gives information about the subject, such as a condition or relationship. They do not show any action; but, they link the subject with the rest of the sentence.
I am a student // I wish to be a student.
Here I am the subject but 'student' is not the object, but rather a 'state' or condition of being.
Who do you wish to be?
I wish to be a student.
Well, you can be whoever you wish to be.
(3) In short, 'who/whom we wish to be' does not need an object pronoun and therefore 'whoever' is to be used here.
This answer uses a somewhat different line of reasoning (from my previous answer), which is why I have presented it as a separate answer to OP's question.
You are right that 'this complex sentence' needs an object for the transitive verb form 'pretend to be'...
Definition of pretend [transitive verb] 1 : to give a false appearance of being, possessing, or performing
does not pretend to be a psychiatrist.
...and that object according to your sentence is the noun clause "whoever/whomever we wish to be" -- now it is a question of deciding whether the verb form 'wish to be' needs an object:
I found the form 'wish to be' defined as an intransitive verb here:
Wish verb 2 [intransitive] to want to do something; to want something to happen
I don't wish to be rude, but could you be a little quieter// I wish to speak to the manager.
Intransitive means it does not need an object, so the object pronoun 'whomever' is not to be used, which is the answer to your question: so use "whoever."
On the other hand, if 'wish to be' is replaced by a transitive verb form like 'wish to see' or 'wish to meet' then whomever is to be chosen as the object pronoun.