Let $Y$ be the dependent variable, $X$ be the independent variable of interest, and $G_i$ be the group indicator with $i\in\{1,2,3,4,5\}$. Both $X$ and $Y$ are continuous. To study the association between $X$ and $Y$, one approach would be to run separate regressions for each group, i.e., $$Y=\beta_0+\beta_{1i}X+\epsilon.$$
In the spirit of this post, would it also make sense to estimate one regression for all five groups as follows? $$Y=\beta_0+\beta_1 X_1+\beta_2 X_2+\beta_3 X_3+\beta_4 X_4+\beta_5 X_5+\epsilon$$ In the equation above, $X_i=X$ when the observation belongs to group $i$ and 0 otherwise.
I understand the first and the second approach differs in the assumptions regarding $\epsilon$. Putting that aside, would it be appropriate to interpret $\beta_1$...$\beta_5$ as the association between $X$ and $Y$ for group $i\in\{1,...,5\}$?
Suppose I perform a Wald test of coefficient equality, e.g., testing if $\beta_1=\beta_2$, can I interpret this test as testing whether the association between $X$ and $Y$ differs between groups $1$ and $2$?