Yes, with some compromises.
The easiest way is to take 5 levels of the appropriate spellcaster. Unfortunately it is not on the Wizard spell list so Arcane Trickster is out of the question as far as RAW is concerned. But it is on the Bard list, and Bard meshes very well with Rogue. It is also on the Cleric list, and the Trickster Cleric is hella cool, and very Rogue like.
Other, more esoteric solutions.
Take the Ritual Caster Feat; pick a divination ritual, like Divination, Contact Other Plane, Augury, etc.; "reskin" the spell to be you talking to dead things.
Take the Magic Initiate Feat; pick a 1st level divination spell &/or a cantrip; "reskin" it. (Not many good options here though)
Go with the thief subclass; take use magic item; get an item that allows you to speak with the dead - you can use it 'cause you spent time with necromancers.
Get a hold of a ring of spell storing, ioun stone (reserve), or similar item. Have a friendly bard or cleric in the party. (Not as satisfying, I bet though as it is clearly not part of the character....)
Pump your Int; get expertise in knowledge skills; "reskin" skill checks as talking with the dead. If you fail a check, well sometimes the dead don't know the answer.