In conversation with my friend, I said:
Er mag zwar ein richtiger kleiner Unruhestifter gewesen sein und hatte vielleicht immer nur Unfug im Kopf, aber wenn er sich etwas in den Kopf gesetzt hatte, dann wollte er es auch unbedingt bis zum Ende durchziehen.
I get the impression that the expression "etw. im Kopf haben" often, if not always, has a pejorative connotation, used with a noun like "Unfug" in my phrasing, whereas the expression "sich etw. in den Kopf setzen" has a positive sense, often coupled with a noun like "Ziel".
But I'm not sure if I'm on the right track here, all the more because this would make for an interesting contrast to French where it works the other way around:
The expression "se mettre en tête" -- literally translating as "sich etw. in den Kopf setzen" -- almost always has a pejorative connotation in French, while the expression "avoir qch. en tête" -- literally translating as "etw. im Kopf haben" -- per se is neutral and can take on a positive or negative meaning, depending on the noun used.