Given a line segment $AB$ in the Euclidean plane, the locus of points which form a right angle with $A$ and $B$ is known to be a circle, with $AB$ as a diameter.

Is this also true for a geodesic segment $AB$ in spherical or hyperbolic space?
In spherical space, let's assume that the distance from $A$ to $B$ is less than $\pi/2$ (but feel free to discuss what happens otherwise).
No, this is not true in general.
When $A$ and $B$ are very close to each other, the solutions approximate a circle, of course (plus its antipodal circle in the case of spherical geometry).
However, as $A$ and $B$ move away from each other, this nice shape cannot be kept, In the spherical case, as the the distance between $A$ and $B$ approaches $\pi/2$, the solution set will approach the union of the two great circles centered on $A$ and $B$. This means that for a distance of $\pi/2-\varepsilon$, the solution curve will be sharply curved near the point where those two great circles intersect, and will be almost straight (that is, geodesic) where it passes through $A$ and $B$.
In the hyperbolic case, no matter how far $A$ and $B$ get from each other, no part of the solution can be farther away from the line $AB$ than $\log(1+\sqrt 2)$ which is the height of a 0-0-90 triangle. So the solution curve will be a long and (relatively) skinny oval when $A$ and $B$ are distant from each other.