Yes, R&D tax credits can be claimed for unsuccessful R&D projects. There is no guarantee of project success when conducting R&D within your company. Independent of whether a project fails, HMRC clearly states that you can still claim tax relief, as long as the project fits the eligible activities criteria.
R&D tax credits are not viewed as a reward for success. Rather, they are intended to be viewed as an incentive to develop projects and encourage businesses to take risks.
The comprehensive R D tax credits explained article is a guide to R&D tax credits that explains the various scenarios which you need to consider in making your claim.