Is it better to have no publication than having you as second author?
If the paper is well-written, contributes non-trivial knowledge to a particular field, is peer-reviewed, and you contributed significantly enough to the paper to be listed as an author, you should put your name on it. In the case of fields where pre-prints are common (i.e., it won't be peer-reviewed, at least initially), it is also worthwhile.

What you don't want is to be an author on a poorly written paper. In other words, you should be proud to list a publication on your CV even if it isn't exactly in your primary research area. Especially at this stage in the game, having a few good papers will help your case, even as a second author (and keep in mind that some fields, such as theoretical computer science, should have the authors listed alphabetically and all authors are considered primary).