To use a sandbox account (not your Apple ID), you must first add it to App Store Connect (https://appstoreconnect.apple.com/).
Then do the following on your device:
Go to Settings > App Store
Enter the login-password for the account in the "Sandbox account" block
Go to Settings > Apple ID
Tap on "Media & Purchases" and tap on "Sign Out"
After testing the subscription, you can cancel it by going back to Settings > App Store > Sandbox account > Manage.
To interact with the App Store and Testflight services again, just go back to Settings > Apple ID and turn on "Media & Purchases" (tap "Continue" in the window).
Topic:
App & System Services
SubTopic:
StoreKit
Tags: