search through post-type attachments titles

You should try applying the s(search) as parameter for your custom query.

See this example here:

$query = new WP_Query( 's=keyword' );

and you can then apply normal loop to iterate through your results. This also performs string match same as like operator %keyword% you mentioned in comment for @Ravs’ answer.

Refer documentation here.