i. When reading a book, he heard a strange sound coming from the outside.
ii. By reading a book, he heard a strange sound coming from the outside.
i is unusual and ii might be ungrammatical.
i rather implies the implausible
i'. Whenever he read a book, he always heard a strange sound.
The following would be more plausible and more "grammatical":
iii. While reading a book, he heard a strange sound.
iii'. Whilst reading a book, he heard a strange sound.
Both iii and iii' (British usage) imply a one-time event.
With reference to ii, by marks an instrumental, agentive, or locative semantic relation:
iv. He opened the bottle by hitting it with a hammer. (instrumental, causative, manner)
v. He put the bottle by the window. (location)
vi. The sound was caused by the book. (agentive, a "passive sentence")
vi seems closest in possible meaning to ii, but it is hard to imagine how the book could cause his hearing so, I'm afraid we can only regard ii as ungrammatical.