It undoubtedly has historic and cultural connections to race, but I do not believe it is offensively racist.
The term lynch refers to what was known as Lynch law - described by the OED as:
The practice of inflicting summary punishment upon an offender, by a
self-constituted court armed with no legal authority; it is now
limited to the summary execution of one charged with some flagrant
offence.
It is undoubtedly true that the vast majority of victims of lynch law were black. So the term lynch has racial connotations but I do not see why it should be considered offensively racist, or why it cannot equally be applied to a white victim of such.
A victim of Lynch Law, moreover, is not necessarily hanged nor, historically, even killed. The term is meant to cover any form of extra-judicial punishment, though I have never heard it used for anything other than hangings (or perhaps strangulations).
The OED is unsure about the etymology of lynch law, but proposes the following:
‘The origin of the expression has not been determined. It is often
asserted to have arisen from the proceedings of Charles Lynch, a
justice of the peace in Virginia, who in 1782 was indemnified by an
act of the Virginia Assembly for having illegally fined and imprisoned
certain Tories in 1780. But Mr. Albert Matthews informs us that no
evidence has been adduced to show that Charles Lynch was ever
concerned in acts such as those which from 1817 onward were designated
as “Lynch's law”. It is possible that the perpetrators of these acts
may have claimed that in the infliction of punishments not sanctioned
by the laws of the country they were following the example of Lynch,
which had been justified by the act of indemnity; or there may have
been some other man of this name who was a ring-leader in such
proceedings. Some have conjectured that the term is derived from the
name of Lynche's Creek, in South Carolina, which is known to have been
in 1768 a meeting-place of the “Regulators”, a band of men whose
professed object was to supply the want of regular administration of
criminal justice in the Carolinas, and who committed many acts of
violence on those suspected of “Toryism”.’ (N.E.D.) The particulars
supplied by Ellicott, together with other evidence, clearly establish
the fact that the originator of Lynch law was Captain William Lynch
(1742–1820) of Pittsylvania in Virginia. According to Ellicott, ‘this
self-created judicial tribunal was first organized in the state of
Virginia about the year 1776’; an article in the Southern Lit.
Messenger (1836) 2 389 gives the date definitely as 1780.