Use an external USB keyboard and mouse.
If both the built-in keyboard and trackpad fail when booted into macOS, then most likely the Tracpad Flex Cable is bad which is very common with the 2015 MBPros. It is possible the failure will behave differently during the diagnostics or before logging into macOS as the built-in keyboard & trackpad may be accessed differently at those times.
If the issue is intermittent, then Apple or an AASP may find it difficult to provide you with the exact cause, but their first attempt at a repair should involve replacing the Trackpad Flex Cable as it is the easiest & least expensive repair possible. If they find the battery is bad, then when they replace the battery a new Trackpad Cable will also be provided since it is a part of the Top Case Assembly which also includes the Keyboard, Trackpad, and Trackpad Flex Cable.
If the Trackpad Flex Cable is not the problem, then either the Trackpad or Logic Board is most likely the problem both of which are much more expensive.