not simple to know what is happening, so I will do a random suggestion here.
Maybe the shader variant you are using have been stripped out by the hdrp stripper, causing the direcitonal light code to not appear. (At least when we see difference between editor and build, it is usually because of this).
But now the question is why the variant have been stripped out. And you can have multiple cause.
is you shader used a builtin shader from hdrp or a custom one you have done or get from somewhere?
could you try the same scene with a builtin shader (like replacign all materials by a lit.shader grey) and see if lighting is correct?
are you using forward or deferred for the lit shader mode?
if it works by replacing by a basic shader, then indeed it may come from incorrect stripping.
I have some legacy shaders in the projects, mostly on particles. Also, there are a couple of custom shaders that I got from an asset, and they don’t even compile because of some error.
deferred
Oh, and I fixed the issue by manually grabbing the light and setting its intensity from code.