I’m sure you could measure brain activity during death to know for sure (but idk under what conditions you’d be able to do that though). It doesn’t really make any sense to me that dying, unless due to some painful external cause, would be painful though. Especially under anesthesia or similar.