You can use the following command:
sed 's/^[^=]\{1,\}=[[:space:]]*$/#&/' file
Explanation:
The s
command means substitute and works like this:
s/search/replace/[optional options]
The patterns above are working as follows:
search
^ Begin of line
[^=]\{1,\} 1 or more non = characters
= The =
[[:space:]]* Optional space before the end of the line
$ The end of the line
replacement
# The #
& The match from the above search
If you want to change the file in place, please check: sed in-place flag that works both on Mac (BSD) and Linux