Yes, scroll bars are already used to identify which operating system you are using as their width varies between systems.
Your user agent already does this.
Which is why many privacy-minded people change their user agent to match the most popular one, especially the OS part.
I imagine you could set up a scrollable div on a page, with elements within and query the position of those elements or their width. Having a custom scroll bar would flow the contained elements in different ways depending on how wide it is.