This verse is the end of an interruption of Paul's main argument, in which he gives the reader extra information. If you have a way to mark an interruption like this in your language, you can use it here.
Here "hearts" is a metonym for the person's thoughts or inner person. The phrase "written in their hearts" is a metaphor for knowing something in their mind. You can translate this in an active form. Alternate translation: "that God has written on their hearts what the law requires them to do" or "that they know the actions that God wants them to do according to his law" (See: [[rc://en/ta/man/jit/figs-metonymy]] and [[rc://en/ta/man/jit/figs-metaphor]] and [[rc://en/ta/man/jit/figs-activepassive]])
Here "bears witness" refers to the knowledge they gain from the law that God has written in their hearts. Alternate translation: "tells them if they are disobeying or obeying God's law" (See: [[rc://en/ta/man/jit/figs-idiom]])