So technically it might be possible to do that. But I don't think the economics would work out for that. Mostly because your cost of hydrogen will then be linked to the cost of electricity coming in. Given the choice between hydrogen which will cost the base electricity prices + overhead of electrolysis plants and transportation or to just use a resistive heater, you would most likely pick the resistive heater since it would be cheaper.
Not saying people should switch to resistive heaters since they significantly less efficient than heat pumps but simply that resistive electric heating would be cheaper than hydrogen (If that hydrogen is produced using electrolysis).
> base electricity prices + overhead of electrolysis plants and transportation
IF the capital cost of electrolysis isn't too bad - and this paper suggests that it can be done more cheaply than the current use of platinum - then it's economical to run them with zero or negative cost electricity produced by renewables overbuild, then keep the hydrogen in tanks (another if) or convert it to actual natural gas via the sabatier reaction and keep that. That may be cheaper than building really huge battery farms for long-duration electric storage.
So negative cost electricity tends to be a side effect of large thermal power plants that can't ramp down quickly due to a drop in demand. Renewables can typically be turned off relatively easily. Maybe there will be situations that might still happen with an over build of renewables but I haven't heard of any. But either way if prices of electricity become very cheap then using that electricity directly with a heat pump or resistive heater also becomes cheaper.
I am not saying making hydrogen can't be economical utilizing cheap off peak rates. I just don't see it as economical for home heating or typical consumer transportation since there are alternatives that utilize electricity directly.
Not saying people should switch to resistive heaters since they significantly less efficient than heat pumps but simply that resistive electric heating would be cheaper than hydrogen (If that hydrogen is produced using electrolysis).