This biography of Einstein (exact page) asserts that, and narrates the dream in astonishing detail. The only chance of it being true is a direct testimony of Einstein himself, but I haven't found it.
According to an article in Nature reviewing Magueijo's earlier book, the story is fictional:
Faster Than the Speed of Light is a lively book that captures the excitement and frustrations of doing real-world science. Magueijo relates interestingly how his VSL proposal might possibly be a way out of some major puzzles facing cosmology, which he explains well. There are irritating passages, however, where he makes extended use of a metaphor involving farmers and cows in explaining relativity theory. Magueijo states that this is based on a dream that Einstein had as a boy — a fictional invention that displays such a cavalier attitude to historical truth as to call into question his other historical claims (and for the record, it was Richard Tolman, not Yakov Zeldovich, who first investigated the thermodynamics of bouncing universes).