See the question and my original answer on StackOverflow

Here is a sample code that will perform a clockwise rotation of 180 degrees on a WinRT's SoftwareBitmap:

// prepare a memory buffer
using var ms = new MemoryStream();

// create an encoder
// set a bitmap transform, here a 180 degrees rotation
var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, ms.AsRandomAccessStream());
encoder.BitmapTransform.Rotation = BitmapRotation.Clockwise180Degrees;

// write the software bitmap to the memory buffer
encoder.SetSoftwareBitmap(softwareBitmap);
await encoder.FlushAsync();

// create a decoder to get the rotated result
var decoder = await BitmapDecoder.CreateAsync(ms.AsRandomAccessStream());

// get the new software bitmap
// Bgra8, Premultiplied are optional
// but mandatory if you want to use it in a SoftwareBitmapSource for example
var rotated = await decoder.GetSoftwareBitmapAsync(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Premultiplied);

Note this is in fact unrelated to WinUI3.