Using this code:
import contextily as ctx
from shapely.geometry import box
import geopandas as gpd
minx, miny = 1.612359e+06, 0.950860e+07
maxx, maxy = 4.320331e+06, 1.007808e+07
rectangle = box(minx, miny, maxx, maxy)
gdf = gpd.GeoDataFrame(
index=['Amazon'],
geometry=[rectangle],
crs='EPSG:5641')
dy = 10e4
ax = gdf.plot(figsize=(8,3), facecolor='none', edgecolor='lime')
ax.set_ylim(miny-dy, maxy+dy)
ctx.add_basemap(ax, crs=gdf.crs.to_string())
To get this plot:
I know it's possible to change the size of the attribution text in contextily, and even to not plot it, but is there a way to change its location, e.g. to write it on the right or at the top?
Similar to how to change leaflet attribution, but for contextily.

It looks like you can't define the attribution in the add_basemap function, and while contextily does provide a more adaptable add_attribution function, that doesn't allow you to specify the text position. There is another way though: manipulate the matplotlib text object generated by add_basemap:
Example output below. Best do this immediately after the add_basemap call to be sure you don't pick up any other text object.