Suppose you have $Var(Y_i|X_i)=\sigma^2, \forall i$, so that the conditional variance of $Y$ given $X$ is constant.
However, as long as the conditional expectation function is not linear, this does not imply that the residuals of the linear regression are homoskedastic.
- To see this is sufficient to write (in the case of one regressor plus the constant): $$E[(Y_i-\beta_0-\beta_1X_i)^2|X_i]=E\{[(Y_i-E[Y_i|X])+(E[Y_i|X]-\beta_0-\beta_1X_i)]^2|X_i\}= Var[Y_i|X_i]+(E[Y_i|X_i]-\beta_0-\beta_1X_i)^2$$
which is in general different from $Var[Y_i|X_i]$ as long as $E[Y_i|X_i]$ is not linear.
- However my concern is the following: whatever is the functional form of the CEF, one can always write $Y_i=\beta_0+\beta_1X_i+u_i$, therefore: $$Var[Y_i|X_i]=Var[(\beta_0+\beta_1X_i+u_i)|X_i]=Var[(\beta_1X_i+u_i)|X_i]\\= Var[\beta_1X_i|X_i]+Var[u_i|X_i]+2\beta_1Cov[X_i,u_i|X_i]$$ since we have (is it true?) $Var[\beta_1X_i|X_i]=0$ and $2\beta_1Cov[X_i,u_i|X_i]=0$, we conclude that $\sigma^2=Var[Y_i|X_i]=Var[u_i|X_i]$ so that errors must be homoskedastic too.