That's not what happens with that sed command on my device (a Mac). I get the same behavior using just sed as I get with doubling the backslash (i.e. escaping the backslash:
system("sed -i -e 's/^/#\\x27 /\' file.txt")
In both cases I see #\x27 in the text.