You want to cheat a bot, which Google don't use it for ranking. Pagespeed insights/lighthouse etc are just for our own analysis purpose, Google don't use that bot at all to determine your web pagespeed. Google just come with their own bot name, Googlebot and crawl your content and major pagespeed.
And if you serve different content to Googlebot then it will term as cloaking. Bur normally if you block some javascript/ajax file which is just for web design purpose then it's totally fine, but do it via robots.txt file only.
I've seen some people block javascript file which download fonts online. Google don't recommended to do even such a thing, but if webmaster do it then there is no any penalty. Because whatever you've block via robots.txt, then it will notify you, in your search console to know what you've blocked it and how they see your content.