How can you make it automatically invisible to render if its already invisible in viewport?
Handlers

Could set in a handler. bpy.app.handlers.depsgraph_update_[pre or post] are the v2.8x equivalent of scene update in versions prior.

Run this script once. Now every time the depsgraph updates ( a lot ) it will match the hide render attribute to the objects hide status.

import bpy

def hide(scene):
    for o in scene.objects:
        o.hide_render = o.hide_get()

    return None

# uncomment to clear all
#bpy.app.handlers.depsgraph_update_post.clear()
bpy.app.handlers.depsgraph_update_post.append(hide)