You can use PointerPressed event.
A quick test with a TreeView from WinUI3 Gallery and a simple MenuFlyout from the TreeViewNode text, to be improved :
private void Tv1_PointerPressed(object sender, PointerRoutedEventArgs e)
{
var properties = e.GetCurrentPoint((UIElement)sender).Properties;
if (properties.IsRightButtonPressed)
{
var dc = ((FrameworkElement)e.OriginalSource).DataContext;
MenuFlyout mf = new MenuFlyout();
MenuFlyoutItem mfi = new MenuFlyoutItem();
mfi.Text = ((TreeViewNode)dc).Content.ToString();
mf.Items.Add(mfi);
Microsoft.UI.Input.PointerPoint pp = e.GetCurrentPoint((UIElement)sender);
Point ptElement = new Point(pp.Position.X, pp.Position.Y);
mf.ShowAt((FrameworkElement)sender, ptElement);
}
}