You can achieve that using Scroll into view interaction. The trick is to apply it on a different section other than your navbar. Because if you navbar is in fixed position we cannot detect scroll position with it.
So we have to apply interaction to another section. And depending on the position of that section we can trigger animation to be applied on your navbar.
Suppose you’ve a Hero Section below your navbar, apply Scroll into view interaction on it. Now create animation for Scrolled out of view, this means when you scroll past the Hero Section changes will appear on the navbar.
And for Scrolled into view reset everything to make it normal. That means when you scroll back to Hero Section your navbar will change to normal.
To change the logo size you just have to animate width/height in the actions.
If you want to have image change effect, place 2 logos and keep small one hidden and when animating hide bigger one and show smaller one. Do this with animating width/height so your changes will look smooth.
To do like your example, place 2 separate logos and while animating to small size, hide the bigger logo.