Yep, it can. Although you would want the server to be spending time doing something productive rather than just idling or spinning worthless cycles
There are people who use GPUs and ASICs mining cryptocurrency as heaters for greenhouses. Spending the energy on crypto mining is basically a way to recoup some of your energy costs. https://cointelegraph.com/news/cryptomatoes-grows-5-acres-of...