Add phpcaptcha in contact form 7 with validation in WordPress which you can download from below w3schools website.

PHP Captcha

1. Extract phptextcaptcha in your theme directory of wordpress.

your directory will be like.

yourthemepath/phpcaptcha/css
yourthemepath/phpcaptcha/font
yourthemepath/phpcaptcha/captcha.php
yourthemepath/phpcaptcha/phptextClass.php

where captcha.php path will be generating an image and put the value of it session $_SESSION[‘captcha_code’];

2. In contact form you need to put

you can further style this with css.

3. Now last part is validating this with contact form 7.

put the code in function.php