I imagine it's quite possible, but updating a bunch of cells with new lighting data while a pawn is moving might be fairly intensive.
As for how to do it, I think the first trick is figuring out how to make a matrix of values from an angle (the direction a pawn is facing in) and the distance which the flashlight can illuminate. This is something which can be pre-calculated once and turned into a lighting offset array - basically, only the tiles which you want to light, relative to the pawn's position.
You can make further optimisations by looking at the existing lighting code to see if there's a cheap way of lighting multiple tiles e.g. whether you can specify a rectangular area - if so, you can find the biggest rectangle in the offset array and save yourself having to go through all of those individually. Then, having done all of this, you need not re-calculate all of these, just stash them in memory to retrieve later.
I know that Mining&Co collection of mods has a mining helmet which gives off light, so having an equipped flashlight is certainly possible.