Recently I read Wald test for logistic regression this post, which states why do we use Wald test in logistic regression and no t-test instead. It says, that the main reason behind it, is that for example in OLS the variance of residuals is unknown, and it has to be estimated, so t-test has to be used. On the another hand, since logistic regression is estimated using maximum likelihood estimation, we know that $\hat \beta - \beta$ will be asymptotically normally distributed, and therefore the expression:
$$W = \frac{\hat \beta - \beta}{\hat{\textrm{se}}(\hat \beta)}$$
will have asymptotically standard normal distribution. Where of course:
$$\hat{\textrm{se}}(\hat \beta) = \sqrt{s^2(X^TX)^{-1}_{jj}}$$
and $s^2$ is a variance of residuals.
I understand, that in linear regression, you replace $s^2$ by its estimator $\hat \sigma^2$, and then statistics $W$ has t-student distribution instead of normal. However, when you fit exactly the variance, $W$ statistics will have asymptotically normal distribution. And here I couldn't find any information how exactly this variance in logistic regression can be found. Could you please explain to me how it can be dervied?