What is the word for when a writer spells words of a character's dialogue differently for a character in order to express an accent or dialect? I think it starts with a 'd'.
This is called phonetic transcription:
the visual representation of speech sounds
When I saw your description, my mind instantly went to Zora Neale Hurston's Their Eyes Were Watching God, which uses phonetic transcription throughout the entirety of the book.
“If God don’t think no mo’ ’bout ’em then Ah do, they’s a lost ball in de high grass.”