Can you invest in the stock market while receiving social security disability benefits?

Yes, and in any other investment, since SSDI is simply accelerated Social Security Benefits you would be entitled to due to your work history and the fact you paid taxes during your working career. The SS administration simply estimates what a disabled person would get at full retirement age had they not been disabled and pays the benefit to the disabled person when they qualify as disabled. So, the money is up to the recipient to do with as they please and has nothing to do with checking accounts or savings account or any other assets.
SSI benefits, confused with SSDI, is "needs based" and IS affected by a low-income persons assets.