Work may be done in positive or negative direction. When a work is done in positive direction, it is called useful work, when work is done in negative direction, it is known as useless work. Any energy associated with friction produces useless work. That is, the work is done in negative direction.
Therefore, thermal energy produced by friction can be used to do work but in negative direction.