Two approaches:
Network isolation/DNS blocking - put the TV on a VLAN and only permit specific ports through to a media server (whatever the TV will support). If you lack VLAN capability, run PiHole as your DNS server (it works best as DNS and DHCP, but that's just my opinion for things I like, such as proper name resolution for all devices).
Second option: (your idea with a Pi) disconnect TV from network entirely, then run something like Kodi (or whatever media center you prefer) on an old laptop, mini-PC, whatever, and have that device connect via HDMI. HDMI can passthrough the navigation controls from the TV remote (not guaranteed, but it's part of the standard). I looked into this a long time ago but the performance wasn't there yet. Today I'd probably try any distro and run Kodi on it.
Even my POS Samsung passes through enough of the controls to navigate Kodi on a 2017 laptop, while retaining power, volume, settings, etc for the TV itself.
My current setup is a Jellyfin server and Jellyfin client on the TV. I run PiHole with a blocklist for all the Samsung BS which has had the side effect of making the TV menus faster as it doesn't retrieve any "what's new" info from Samsung. Its actually kind of fun to monitor the FNS log and see the domains the TV hits, click Deny and see what breaks in the TV. On average about 30% of all DNS requests on my network get denied, and nothing of value has been lost. That's how much crap is being sent all the time.
Hope that gives you some ideas.