I am able to change the background of a range of lines in code mirror with the below code:
javaEditor.markText( { line: 0, ch: 0 }, { line: 2, ch: 0 }