I would actually say that "hold up" doesn't sound as correct as "keep up" in this case. Hold up sounds like the boy is physically lifting something, where keep up sounds more like a figurative idea, as courage would be considered, in my opinion.
Ideally, I would change the sentence to read, "Walking alone in the dark, the boy whistled to maintain his courage."