"someone passing themselves off as them" is technically correct but it is very hard to read because the people that "someone", "themselves" and "them" refer to each take effort to keep straight.
A cleaner way to say this, with differences highlighted:
Sometimes you need to know if the book was really written by the accredited author instead of someone else.
If you wish to use the idiom, "passing themselves off as" it could look something like this:
Sometimes you need to know if the book was really written by someone passing themselves off as the accredited author.
The two primary changes are (a) replacing "the author it claims to be" with "the accredited author" which reduces the complexity of that clause and (b) moves the reference to the author to the end of the sentence so it can replace "them".
Now there is only "someone else" and "themselves" and they refer to the same entity. You could accomplish the same thing without using "accredited" but I find removing the extra "it" helps because moving "it claims to be written by" doesn't work very well at the end. Here it is with your original phrasing:
Sometimes you need to know if the book was really written by someone passing themselves off as the author [the book] claims to be [written by].